/*
* This file is provided under a GPLv2 license. When using or
* redistributing this file, you may do so under that license.
*
* GPL LICENSE SUMMARY
*
* Copyright (C) 2016 T-Platforms. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, it can be found <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* IDT PCIe-switch NTB Linux driver
*
* Contact Information:
* Serge Semin <fancer.lancer@gmail.com>, <Sergey.Semin@t-platforms.ru>
*/
/*
* NOTE of the IDT 89HPESx SMBus-slave interface driver
* This driver primarily is developed to have an access to EEPROM device of
* IDT PCIe-switches. IDT provides a simple SMBus interface to perform IO-
* operations from/to EEPROM, which is located at private (so called Master)
* SMBus of switches. Using that interface this the driver creates a simple
* binary sysfs-file in the device directory:
* /sys/bus/i2c/devices/<bus>-<devaddr>/eeprom
* In case if read-only flag is specified in the dts-node of device desription,
* User-space applications won't be able to write to the EEPROM sysfs-node.
* Additionally IDT 89HPESx SMBus interface has an ability to write/read
* data of device CSRs. This driver exposes debugf-file to perform simple IO
* operations using that ability for just basic debug purpose. Particularly
* next file is created in the specific debugfs-directory:
* /sys/kernel/debug/idt_csr/
* Format of the debugfs-node is:
* $ cat /sys/kernel/debug/idt_csr/<bus>-<devaddr>/<devname>;
* <CSR address>:<CSR value>
* So reading the content of the file gives current CSR address and it value.
* If User-space application wishes to change current CSR address,
* it can just write a proper value to the sysfs-file:
* $ echo "<CSR address>" > /sys/kernel/debug/idt_csr/<bus>-<devaddr>/<devname>
* If it wants to change the CSR value as well, the format of the write
* operation is:
* $ echo "<CSR address>:<CSR value>" > \
* /sys/kernel/debug/idt_csr/<bus>-<devaddr>/<devname>;
* CSR address and value can be any of hexadecimal, decimal or octal format.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/debugfs.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/i2c.h>
#include <linux/pci_ids.h>
#include &
|