Commit d2d8f51e authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:

 - new drivers for Spreadtrum I2C, Intel Cherry Trail Whiskey Cove SMBUS

 - quite some driver updates

 - cleanups for the i2c-mux subsystem

 - some subsystem-wide constification

 - further cleanup of include/linux/i2c

* 'i2c/for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (50 commits)
  i2c: sprd: Fix undefined reference errors
  i2c: nomadik: constify amba_id
  i2c: versatile: Make i2c_algo_bit_data const
  i2c: busses: make i2c_adapter_quirks const
  i2c: busses: make i2c_adapter const
  i2c: busses: make i2c_algorithm const
  i2c: Add Spreadtrum I2C controller driver
  dt-bindings: i2c: Add Spreadtrum I2C controller documentation
  i2c-cht-wc: make cht_wc_i2c_adap_driver static
  MAINTAINERS: Add entry for drivers/i2c/busses/i2c-cht-wc.c
  i2c: aspeed: Retain delay/setup/hold values when configuring bus frequency
  dt-bindings: i2c: eeprom: Document vendor to be used and deprecated ones
  i2c: i801: Restore the presence state of P2SB PCI device after reading BAR
  MAINTAINERS: drop entry for Blackfin I2C and Sonic's email
  blackfin: merge the two TWI header files
  i2c: davinci: Preserve return value of devm_clk_get
  i2c: mediatek: Add i2c compatible for MediaTek MT7622
  dt-bindings: i2c: Add MediaTek MT7622 i2c binding
  dt-bindings: i2c: modify information formats
  i2c: mux: i2c-arb-gpio-challenge: allow compiling w/o OF support
  ...
parents ad9a19d0 8ce906c1
...@@ -16,8 +16,12 @@ Required properties: ...@@ -16,8 +16,12 @@ Required properties:
"renesas,r1ex24002" "renesas,r1ex24002"
The following manufacturers values have been deprecated:
"at", "at24"
If there is no specific driver for <manufacturer>, a generic If there is no specific driver for <manufacturer>, a generic
driver based on <type> is selected. Possible types are: device with <type> and manufacturer "atmel" should be used.
Possible types are:
"24c00", "24c01", "24c02", "24c04", "24c08", "24c16", "24c32", "24c64", "24c00", "24c01", "24c02", "24c04", "24c08", "24c16", "24c32", "24c64",
"24c128", "24c256", "24c512", "24c1024", "spd" "24c128", "24c256", "24c512", "24c1024", "spd"
......
* Mediatek's I2C controller * MediaTek's I2C controller
The Mediatek's I2C controller is used to interface with I2C devices. The MediaTek's I2C controller is used to interface with I2C devices.
Required properties: Required properties:
- compatible: value should be either of the following. - compatible: value should be either of the following.
"mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for Mediatek mt2701 "mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for MediaTek MT2701
"mediatek,mt6577-i2c": for i2c compatible with mt6577. "mediatek,mt6577-i2c": for MediaTek MT6577
"mediatek,mt6589-i2c": for i2c compatible with mt6589. "mediatek,mt6589-i2c": for MediaTek MT6589
"mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for i2c compatible with mt7623. "mediatek,mt7622-i2c": for MediaTek MT7622
"mediatek,mt8173-i2c": for i2c compatible with mt8173. "mediatek,mt7623-i2c", "mediatek,mt6577-i2c": for MediaTek MT7623
"mediatek,mt8173-i2c": for MediaTek MT8173
- reg: physical base address of the controller and dma base, length of memory - reg: physical base address of the controller and dma base, length of memory
mapped region. mapped region.
- interrupts: interrupt number to the cpu. - interrupts: interrupt number to the cpu.
......
...@@ -2,6 +2,8 @@ I2C for R-Car platforms ...@@ -2,6 +2,8 @@ I2C for R-Car platforms
Required properties: Required properties:
- compatible: - compatible:
"renesas,i2c-r8a7743" if the device is a part of a R8A7743 SoC.
"renesas,i2c-r8a7745" if the device is a part of a R8A7745 SoC.
"renesas,i2c-r8a7778" if the device is a part of a R8A7778 SoC. "renesas,i2c-r8a7778" if the device is a part of a R8A7778 SoC.
"renesas,i2c-r8a7779" if the device is a part of a R8A7779 SoC. "renesas,i2c-r8a7779" if the device is a part of a R8A7779 SoC.
"renesas,i2c-r8a7790" if the device is a part of a R8A7790 SoC. "renesas,i2c-r8a7790" if the device is a part of a R8A7790 SoC.
...@@ -12,7 +14,8 @@ Required properties: ...@@ -12,7 +14,8 @@ Required properties:
"renesas,i2c-r8a7795" if the device is a part of a R8A7795 SoC. "renesas,i2c-r8a7795" if the device is a part of a R8A7795 SoC.
"renesas,i2c-r8a7796" if the device is a part of a R8A7796 SoC. "renesas,i2c-r8a7796" if the device is a part of a R8A7796 SoC.
"renesas,rcar-gen1-i2c" for a generic R-Car Gen1 compatible device. "renesas,rcar-gen1-i2c" for a generic R-Car Gen1 compatible device.
"renesas,rcar-gen2-i2c" for a generic R-Car Gen2 compatible device. "renesas,rcar-gen2-i2c" for a generic R-Car Gen2 or RZ/G1 compatible
device.
"renesas,rcar-gen3-i2c" for a generic R-Car Gen3 compatible device. "renesas,rcar-gen3-i2c" for a generic R-Car Gen3 compatible device.
"renesas,i2c-rcar" (deprecated) "renesas,i2c-rcar" (deprecated)
......
...@@ -7,6 +7,7 @@ Required properties : ...@@ -7,6 +7,7 @@ Required properties :
- reg : Offset and length of the register set for the device - reg : Offset and length of the register set for the device
- compatible: should be one of the following: - compatible: should be one of the following:
- "rockchip,rv1108-i2c": for rv1108
- "rockchip,rk3066-i2c": for rk3066 - "rockchip,rk3066-i2c": for rk3066
- "rockchip,rk3188-i2c": for rk3188 - "rockchip,rk3188-i2c": for rk3188
- "rockchip,rk3228-i2c": for rk3228 - "rockchip,rk3228-i2c": for rk3228
......
...@@ -4,6 +4,8 @@ Required properties: ...@@ -4,6 +4,8 @@ Required properties:
- compatible : - compatible :
- "renesas,iic-r8a73a4" (R-Mobile APE6) - "renesas,iic-r8a73a4" (R-Mobile APE6)
- "renesas,iic-r8a7740" (R-Mobile A1) - "renesas,iic-r8a7740" (R-Mobile A1)
- "renesas,iic-r8a7743" (RZ/G1M)
- "renesas,iic-r8a7745" (RZ/G1E)
- "renesas,iic-r8a7790" (R-Car H2) - "renesas,iic-r8a7790" (R-Car H2)
- "renesas,iic-r8a7791" (R-Car M2-W) - "renesas,iic-r8a7791" (R-Car M2-W)
- "renesas,iic-r8a7792" (R-Car V2H) - "renesas,iic-r8a7792" (R-Car V2H)
...@@ -12,7 +14,8 @@ Required properties: ...@@ -12,7 +14,8 @@ Required properties:
- "renesas,iic-r8a7795" (R-Car H3) - "renesas,iic-r8a7795" (R-Car H3)
- "renesas,iic-r8a7796" (R-Car M3-W) - "renesas,iic-r8a7796" (R-Car M3-W)
- "renesas,iic-sh73a0" (SH-Mobile AG5) - "renesas,iic-sh73a0" (SH-Mobile AG5)
- "renesas,rcar-gen2-iic" (generic R-Car Gen2 compatible device) - "renesas,rcar-gen2-iic" (generic R-Car Gen2 or RZ/G1
compatible device)
- "renesas,rcar-gen3-iic" (generic R-Car Gen3 compatible device) - "renesas,rcar-gen3-iic" (generic R-Car Gen3 compatible device)
- "renesas,rmobile-iic" (generic device) - "renesas,rmobile-iic" (generic device)
......
I2C for Spreadtrum platforms
Required properties:
- compatible: Should be "sprd,sc9860-i2c".
- reg: Specify the physical base address of the controller and length
of memory mapped region.
- interrupts: Should contain I2C interrupt.
- clock-names: Should contain following entries:
"i2c" for I2C clock,
"source" for I2C source (parent) clock,
"enable" for I2C module enable clock.
- clocks: Should contain a clock specifier for each entry in clock-names.
- clock-frequency: Constains desired I2C bus clock frequency in Hz.
- #address-cells: Should be 1 to describe address cells for I2C device address.
- #size-cells: Should be 0 means no size cell for I2C device address.
Optional properties:
- Child nodes conforming to I2C bus binding
Examples:
i2c0: i2c@70500000 {
compatible = "sprd,sc9860-i2c";
reg = <0 0x70500000 0 0x1000>;
interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
clock-names = "i2c", "source", "enable";
clocks = <&clk_i2c3>, <&ext_26m>, <&clk_ap_apb_gates 11>;
clock-frequency = <400000>;
#address-cells = <1>;
#size-cells = <0>;
};
...@@ -42,6 +42,10 @@ i2c-arb-gpio-challenge Parent-locked ...@@ -42,6 +42,10 @@ i2c-arb-gpio-challenge Parent-locked
i2c-mux-gpio Normally parent-locked, mux-locked iff i2c-mux-gpio Normally parent-locked, mux-locked iff
all involved gpio pins are controlled by the all involved gpio pins are controlled by the
same i2c root adapter that they mux. same i2c root adapter that they mux.
i2c-mux-gpmux Normally parent-locked, mux-locked iff
specified in device-tree.
i2c-mux-ltc4306 Mux-locked
i2c-mux-mlxcpld Parent-locked
i2c-mux-pca9541 Parent-locked i2c-mux-pca9541 Parent-locked
i2c-mux-pca954x Parent-locked i2c-mux-pca954x Parent-locked
i2c-mux-pinctrl Normally parent-locked, mux-locked iff i2c-mux-pinctrl Normally parent-locked, mux-locked iff
...@@ -50,9 +54,11 @@ i2c-mux-pinctrl Normally parent-locked, mux-locked iff ...@@ -50,9 +54,11 @@ i2c-mux-pinctrl Normally parent-locked, mux-locked iff
i2c-mux-reg Parent-locked i2c-mux-reg Parent-locked
In drivers/iio/ In drivers/iio/
gyro/mpu3050 Mux-locked
imu/inv_mpu6050/ Mux-locked imu/inv_mpu6050/ Mux-locked
In drivers/media/ In drivers/media/
dvb-frontends/lgdt3306a Mux-locked
dvb-frontends/m88ds3103 Parent-locked dvb-frontends/m88ds3103 Parent-locked
dvb-frontends/rtl2830 Parent-locked dvb-frontends/rtl2830 Parent-locked
dvb-frontends/rtl2832 Mux-locked dvb-frontends/rtl2832 Mux-locked
......
...@@ -2575,13 +2575,6 @@ W: http://blackfin.uclinux.org ...@@ -2575,13 +2575,6 @@ W: http://blackfin.uclinux.org
S: Supported S: Supported
F: drivers/net/ethernet/adi/ F: drivers/net/ethernet/adi/
BLACKFIN I2C TWI DRIVER
M: Sonic Zhang <sonic.zhang@analog.com>
L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers)
W: http://blackfin.uclinux.org/
S: Supported
F: drivers/i2c/busses/i2c-bfin-twi.c
BLACKFIN MEDIA DRIVER BLACKFIN MEDIA DRIVER
M: Scott Jiang <scott.jiang.linux@gmail.com> M: Scott Jiang <scott.jiang.linux@gmail.com>
L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers)
...@@ -2598,14 +2591,12 @@ S: Supported ...@@ -2598,14 +2591,12 @@ S: Supported
F: drivers/rtc/rtc-bfin.c F: drivers/rtc/rtc-bfin.c
BLACKFIN SDH DRIVER BLACKFIN SDH DRIVER
M: Sonic Zhang <sonic.zhang@analog.com>
L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers)
W: http://blackfin.uclinux.org W: http://blackfin.uclinux.org
S: Supported S: Supported
F: drivers/mmc/host/bfin_sdh.c F: drivers/mmc/host/bfin_sdh.c
BLACKFIN SERIAL DRIVER BLACKFIN SERIAL DRIVER
M: Sonic Zhang <sonic.zhang@analog.com>
L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers)
W: http://blackfin.uclinux.org W: http://blackfin.uclinux.org
S: Supported S: Supported
...@@ -6441,6 +6432,12 @@ F: drivers/i2c/busses/i2c-sis96x.c ...@@ -6441,6 +6432,12 @@ F: drivers/i2c/busses/i2c-sis96x.c
F: drivers/i2c/busses/i2c-via.c F: drivers/i2c/busses/i2c-via.c
F: drivers/i2c/busses/i2c-viapro.c F: drivers/i2c/busses/i2c-viapro.c
I2C/SMBUS INTEL CHT WHISKEY COVE PMIC DRIVER
M: Hans de Goede <hdegoede@redhat.com>
L: linux-i2c@vger.kernel.org
S: Maintained
F: drivers/i2c/busses/i2c-cht-wc.c
I2C/SMBUS ISMT DRIVER I2C/SMBUS ISMT DRIVER
M: Seth Heasley <seth.heasley@intel.com> M: Seth Heasley <seth.heasley@intel.com>
M: Neil Horman <nhorman@tuxdriver.com> M: Neil Horman <nhorman@tuxdriver.com>
......
/* /*
* bfin_twi.h - interface to Blackfin TWIs * bfin_twi.h - interface to Blackfin TWIs
* *
* Copyright 2005-2010 Analog Devices Inc. * Copyright 2005-2014 Analog Devices Inc.
* *
* Licensed under the GPL-2 or later. * Licensed under the GPL-2 or later.
*/ */
...@@ -10,6 +10,138 @@ ...@@ -10,6 +10,138 @@
#define __ASM_BFIN_TWI_H__ #define __ASM_BFIN_TWI_H__
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <linux/types.h>
#include <linux/i2c.h>
/*
* ADI twi registers layout
*/
struct bfin_twi_regs {
u16 clkdiv;
u16 dummy1;
u16 control;
u16 dummy2;
u16 slave_ctl;
u16 dummy3;
u16 slave_stat;
u16 dummy4;
u16 slave_addr;
u16 dummy5;
u16 master_ctl;
u16 dummy6;
u16 master_stat;
u16 dummy7;
u16 master_addr;
u16 dummy8;
u16 int_stat;
u16 dummy9;
u16 int_mask;
u16 dummy10;
u16 fifo_ctl;
u16 dummy11;
u16 fifo_stat;
u16 dummy12;
u32 __pad[20];
u16 xmt_data8;
u16 dummy13;
u16 xmt_data16;
u16 dummy14;
u16 rcv_data8;
u16 dummy15;
u16 rcv_data16;
u16 dummy16;
};
struct bfin_twi_iface {
int irq;
spinlock_t lock;
char read_write;
u8 command;
u8 *transPtr;
int readNum;
int writeNum;
int cur_mode;
int manual_stop;
int result;
struct i2c_adapter adap;
struct completion complete;
struct i2c_msg *pmsg;
int msg_num;
int cur_msg;
u16 saved_clkdiv;
u16 saved_control;
struct bfin_twi_regs __iomem *regs_base;
};
/* ******************** TWO-WIRE INTERFACE (TWI) MASKS ********************/
/* TWI_CLKDIV Macros (Use: *pTWI_CLKDIV = CLKLOW(x)|CLKHI(y); ) */
#define CLKLOW(x) ((x) & 0xFF) /* Periods Clock Is Held Low */
#define CLKHI(y) (((y)&0xFF)<<0x8) /* Periods Before New Clock Low */
/* TWI_PRESCALE Masks */
#define PRESCALE 0x007F /* SCLKs Per Internal Time Reference (10MHz) */
#define TWI_ENA 0x0080 /* TWI Enable */
#define SCCB 0x0200 /* SCCB Compatibility Enable */
/* TWI_SLAVE_CTL Masks */
#define SEN 0x0001 /* Slave Enable */
#define SADD_LEN 0x0002 /* Slave Address Length */
#define STDVAL 0x0004 /* Slave Transmit Data Valid */
#define NAK 0x0008 /* NAK Generated At Conclusion Of Transfer */
#define GEN 0x0010 /* General Call Address Matching Enabled */
/* TWI_SLAVE_STAT Masks */
#define SDIR 0x0001 /* Slave Transfer Direction (RX/TX*) */
#define GCALL 0x0002 /* General Call Indicator */
/* TWI_MASTER_CTL Masks */
#define MEN 0x0001 /* Master Mode Enable */
#define MADD_LEN 0x0002 /* Master Address Length */
#define MDIR 0x0004 /* Master Transmit Direction (RX/TX*) */
#define FAST 0x0008 /* Use Fast Mode Timing Specs */
#define STOP 0x0010 /* Issue Stop Condition */
#define RSTART 0x0020 /* Repeat Start or Stop* At End Of Transfer */
#define DCNT 0x3FC0 /* Data Bytes To Transfer */
#define SDAOVR 0x4000 /* Serial Data Override */
#define SCLOVR 0x8000 /* Serial Clock Override */
/* TWI_MASTER_STAT Masks */
#define MPROG 0x0001 /* Master Transfer In Progress */
#define LOSTARB 0x0002 /* Lost Arbitration Indicator (Xfer Aborted) */
#define ANAK 0x0004 /* Address Not Acknowledged */
#define DNAK 0x0008 /* Data Not Acknowledged */
#define BUFRDERR 0x0010 /* Buffer Read Error */
#define BUFWRERR 0x0020 /* Buffer Write Error */
#define SDASEN 0x0040 /* Serial Data Sense */
#define SCLSEN 0x0080 /* Serial Clock Sense */
#define BUSBUSY 0x0100 /* Bus Busy Indicator */
/* TWI_INT_SRC and TWI_INT_ENABLE Masks */
#define SINIT 0x0001 /* Slave Transfer Initiated */
#define SCOMP 0x0002 /* Slave Transfer Complete */
#define SERR 0x0004 /* Slave Transfer Error */
#define SOVF 0x0008 /* Slave Overflow */
#define MCOMP 0x0010 /* Master Transfer Complete */
#define MERR 0x0020 /* Master Transfer Error */
#define XMTSERV 0x0040 /* Transmit FIFO Service */
#define RCVSERV 0x0080 /* Receive FIFO Service */
/* TWI_FIFO_CTRL Masks */
#define XMTFLUSH 0x0001 /* Transmit Buffer Flush */
#define RCVFLUSH 0x0002 /* Receive Buffer Flush */
#define XMTINTLEN 0x0004 /* Transmit Buffer Interrupt Length */
#define RCVINTLEN 0x0008 /* Receive Buffer Interrupt Length */
/* TWI_FIFO_STAT Masks */
#define XMTSTAT 0x0003 /* Transmit FIFO Status */
#define XMT_EMPTY 0x0000 /* Transmit FIFO Empty */
#define XMT_HALF 0x0001 /* Transmit FIFO Has 1 Byte To Write */
#define XMT_FULL 0x0003 /* Transmit FIFO Full (2 Bytes To Write) */
#define RCVSTAT 0x000C /* Receive FIFO Status */
#define RCV_EMPTY 0x0000 /* Receive FIFO Empty */
#define RCV_HALF 0x0004 /* Receive FIFO Has 1 Byte To Read */
#define RCV_FULL 0x000C /* Receive FIFO Full (2 Bytes To Read) */
#define DEFINE_TWI_REG(reg_name, reg) \ #define DEFINE_TWI_REG(reg_name, reg) \
static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \ static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/i2c/bfin_twi.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/i2c/tc35876x.h> #include <linux/platform_data/tc35876x.h>
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
/*tc35876x DSI_LVDS bridge chip and panel platform data*/ /*tc35876x DSI_LVDS bridge chip and panel platform data*/
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "mdfld_output.h" #include "mdfld_output.h"
#include "mdfld_dsi_pkg_sender.h" #include "mdfld_dsi_pkg_sender.h"
#include "tc35876x-dsi-lvds.h" #include "tc35876x-dsi-lvds.h"
#include <linux/i2c/tc35876x.h> #include <linux/platform_data/tc35876x.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/intel_scu_ipc.h> #include <asm/intel_scu_ipc.h>
......
...@@ -189,6 +189,14 @@ config I2C_PIIX4 ...@@ -189,6 +189,14 @@ config I2C_PIIX4
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called i2c-piix4. will be called i2c-piix4.
config I2C_CHT_WC
tristate "Intel Cherry Trail Whiskey Cove PMIC smbus controller"
depends on INTEL_SOC_PMIC_CHTWC
help
If you say yes to this option, support will be included for the
SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC
found on some Intel Cherry Trail systems.
config I2C_NFORCE2 config I2C_NFORCE2
tristate "Nvidia nForce2, nForce3 and nForce4" tristate "Nvidia nForce2, nForce3 and nForce4"
depends on PCI depends on PCI
...@@ -900,6 +908,13 @@ config I2C_SIRF ...@@ -900,6 +908,13 @@ config I2C_SIRF
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called i2c-sirf. will be called i2c-sirf.
config I2C_SPRD
bool "Spreadtrum I2C interface"
depends on I2C=y && ARCH_SPRD
help
If you say yes to this option, support will be included for the
Spreadtrum I2C interface.
config I2C_ST config I2C_ST
tristate "STMicroelectronics SSC I2C support" tristate "STMicroelectronics SSC I2C support"
depends on ARCH_STI depends on ARCH_STI
......
...@@ -12,6 +12,7 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o ...@@ -12,6 +12,7 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o
obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o
obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o
obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
obj-$(CONFIG_I2C_CHT_WC) += i2c-cht-wc.o
obj-$(CONFIG_I2C_I801) += i2c-i801.o obj-$(CONFIG_I2C_I801) += i2c-i801.o
obj-$(CONFIG_I2C_ISCH) += i2c-isch.o obj-$(CONFIG_I2C_ISCH) += i2c-isch.o
obj-$(CONFIG_I2C_ISMT) += i2c-ismt.o obj-$(CONFIG_I2C_ISMT) += i2c-ismt.o
...@@ -89,6 +90,7 @@ obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o ...@@ -89,6 +90,7 @@ obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o
obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o
obj-$(CONFIG_I2C_SPRD) += i2c-sprd.o
obj-$(CONFIG_I2C_ST) += i2c-st.o obj-$(CONFIG_I2C_ST) += i2c-st.o
obj-$(CONFIG_I2C_STM32F4) += i2c-stm32f4.o obj-$(CONFIG_I2C_STM32F4) += i2c-stm32f4.o
obj-$(CONFIG_I2C_STU300) += i2c-stu300.o obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
......
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
#define ASPEED_I2CD_MASTER_EN BIT(0) #define ASPEED_I2CD_MASTER_EN BIT(0)
/* 0x04 : I2CD Clock and AC Timing Control Register #1 */ /* 0x04 : I2CD Clock and AC Timing Control Register #1 */
#define ASPEED_I2CD_TIME_TBUF_MASK GENMASK(31, 28)
#define ASPEED_I2CD_TIME_THDSTA_MASK GENMASK(27, 24)
#define ASPEED_I2CD_TIME_TACST_MASK GENMASK(23, 20)
#define ASPEED_I2CD_TIME_SCL_HIGH_SHIFT 16 #define ASPEED_I2CD_TIME_SCL_HIGH_SHIFT 16
#define ASPEED_I2CD_TIME_SCL_HIGH_MASK GENMASK(19, 16) #define ASPEED_I2CD_TIME_SCL_HIGH_MASK GENMASK(19, 16)
#define ASPEED_I2CD_TIME_SCL_LOW_SHIFT 12 #define ASPEED_I2CD_TIME_SCL_LOW_SHIFT 12
...@@ -132,6 +135,7 @@ struct aspeed_i2c_bus { ...@@ -132,6 +135,7 @@ struct aspeed_i2c_bus {
/* Synchronizes I/O mem access to base. */ /* Synchronizes I/O mem access to base. */
spinlock_t lock; spinlock_t lock;
struct completion cmd_complete; struct completion cmd_complete;
u32 (*get_clk_reg_val)(u32 divisor);
unsigned long parent_clk_frequency; unsigned long parent_clk_frequency;
u32 bus_frequency; u32 bus_frequency;
/* Transaction state. */ /* Transaction state. */
...@@ -675,7 +679,7 @@ static const struct i2c_algorithm aspeed_i2c_algo = { ...@@ -675,7 +679,7 @@ static const struct i2c_algorithm aspeed_i2c_algo = {
#endif /* CONFIG_I2C_SLAVE */ #endif /* CONFIG_I2C_SLAVE */
}; };
static u32 aspeed_i2c_get_clk_reg_val(u32 divisor) static u32 aspeed_i2c_get_clk_reg_val(u32 clk_high_low_max, u32 divisor)
{ {
u32 base_clk, clk_high, clk_low, tmp; u32 base_clk, clk_high, clk_low, tmp;
...@@ -695,16 +699,22 @@ static u32 aspeed_i2c_get_clk_reg_val(u32 divisor) ...@@ -695,16 +699,22 @@ static u32 aspeed_i2c_get_clk_reg_val(u32 divisor)
* Thus, * Thus,
* SCL_freq = APB_freq / * SCL_freq = APB_freq /
* ((1 << base_clk) * (clk_high + 1 + clk_low + 1)) * ((1 << base_clk) * (clk_high + 1 + clk_low + 1))
* The documentation recommends clk_high >= 8 and clk_low >= 7 when * The documentation recommends clk_high >= clk_high_max / 2 and
* possible; this last constraint gives us the following solution: * clk_low >= clk_low_max / 2 - 1 when possible; this last constraint
* gives us the following solution:
*/ */
base_clk = divisor > 33 ? ilog2((divisor - 1) / 32) + 1 : 0; base_clk = divisor > clk_high_low_max ?
tmp = divisor / (1 << base_clk); ilog2((divisor - 1) / clk_high_low_max) + 1 : 0;
clk_high = tmp / 2 + tmp % 2; tmp = (divisor + (1 << base_clk) - 1) >> base_clk;
clk_low = tmp - clk_high; clk_low = tmp / 2;
clk_high = tmp - clk_low;
if (clk_high)
clk_high--;
if (clk_low)
clk_low--;
clk_high -= 1;
clk_low -= 1;
return ((clk_high << ASPEED_I2CD_TIME_SCL_HIGH_SHIFT) return ((clk_high << ASPEED_I2CD_TIME_SCL_HIGH_SHIFT)
& ASPEED_I2CD_TIME_SCL_HIGH_MASK) & ASPEED_I2CD_TIME_SCL_HIGH_MASK)
...@@ -713,13 +723,35 @@ static u32 aspeed_i2c_get_clk_reg_val(u32 divisor) ...@@ -713,13 +723,35 @@ static u32 aspeed_i2c_get_clk_reg_val(u32 divisor)
| (base_clk & ASPEED_I2CD_TIME_BASE_DIVISOR_MASK); | (base_clk & ASPEED_I2CD_TIME_BASE_DIVISOR_MASK);
} }
static u32 aspeed_i2c_24xx_get_clk_reg_val(u32 divisor)
{
/*
* clk_high and clk_low are each 3 bits wide, so each can hold a max
* value of 8 giving a clk_high_low_max of 16.
*/
return aspeed_i2c_get_clk_reg_val(16, divisor);
}
static u32 aspeed_i2c_25xx_get_clk_reg_val(u32 divisor)
{
/*
* clk_high and clk_low are each 4 bits wide, so each can hold a max
* value of 16 giving a clk_high_low_max of 32.
*/
return aspeed_i2c_get_clk_reg_val(32, divisor);
}
/* precondition: bus.lock has been acquired. */ /* precondition: bus.lock has been acquired. */
static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus) static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus)
{ {
u32 divisor, clk_reg_val; u32 divisor, clk_reg_val;
divisor = bus->parent_clk_frequency / bus->bus_frequency; divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency);
clk_reg_val = aspeed_i2c_get_clk_reg_val(divisor); clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1);
clk_reg_val &= (ASPEED_I2CD_TIME_TBUF_MASK |
ASPEED_I2CD_TIME_THDSTA_MASK |
ASPEED_I2CD_TIME_TACST_MASK);
clk_reg_val |= bus->get_clk_reg_val(divisor);
writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1); writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1);
writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2); writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2);
...@@ -778,8 +810,22 @@ static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus) ...@@ -778,8 +810,22 @@ static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus)
return ret; return ret;
} }
static const struct of_device_id aspeed_i2c_bus_of_table[] = {
{
.compatible = "aspeed,ast2400-i2c-bus",
.data = aspeed_i2c_24xx_get_clk_reg_val,
},
{
.compatible = "aspeed,ast2500-i2c-bus",
.data = aspeed_i2c_25xx_get_clk_reg_val,
},
{ },
};
MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table);
static int aspeed_i2c_probe_bus(struct platform_device *pdev) static int aspeed_i2c_probe_bus(struct platform_device *pdev)
{ {
const struct of_device_id *match;
struct aspeed_i2c_bus *bus; struct aspeed_i2c_bus *bus;
struct clk *parent_clk; struct clk *parent_clk;
struct resource *res; struct resource *res;
...@@ -809,6 +855,12 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) ...@@ -809,6 +855,12 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
bus->bus_frequency = 100000; bus->bus_frequency = 100000;
} }
match = of_match_node(aspeed_i2c_bus_of_table, pdev->dev.of_node);
if (!match)
bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val;
else
bus->get_clk_reg_val = match->data;
/* Initialize the I2C adapter */ /* Initialize the I2C adapter */
spin_lock_init(&bus->lock); spin_lock_init(&bus->lock);
init_completion(&bus->cmd_complete); init_completion(&bus->cmd_complete);
...@@ -870,13 +922,6 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev) ...@@ -870,13 +922,6 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id aspeed_i2c_bus_of_table[] = {
{ .compatible = "aspeed,ast2400-i2c-bus", },
{ .compatible = "aspeed,ast2500-i2c-bus", },
{ },
};
MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table);
static struct platform_driver aspeed_i2c_bus_driver = { static struct platform_driver aspeed_i2c_bus_driver = {
.probe = aspeed_i2c_probe_bus, .probe = aspeed_i2c_probe_bus,
.remove = aspeed_i2c_remove_bus, .remove = aspeed_i2c_remove_bus,
......
...@@ -809,7 +809,7 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) ...@@ -809,7 +809,7 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
* The hardware can handle at most two messages concatenated by a * The hardware can handle at most two messages concatenated by a
* repeated start via it's internal address feature. * repeated start via it's internal address feature.
*/ */
static struct i2c_adapter_quirks at91_twi_quirks = { static const struct i2c_adapter_quirks at91_twi_quirks = {
.flags = I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | I2C_AQ_COMB_SAME_ADDR, .flags = I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | I2C_AQ_COMB_SAME_ADDR,
.max_comb_1st_msg_len = 3, .max_comb_1st_msg_len = 3,
}; };
......
...@@ -510,8 +510,7 @@ static int bcm_iproc_i2c_remove(struct platform_device *pdev) ...@@ -510,8 +510,7 @@ static int bcm_iproc_i2c_remove(struct platform_device *pdev)
static int bcm_iproc_i2c_suspend(struct device *dev) static int bcm_iproc_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev);
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
/* make sure there's no pending interrupt when we go into suspend */ /* make sure there's no pending interrupt when we go into suspend */
writel(0, iproc_i2c->base + IE_OFFSET); writel(0, iproc_i2c->base + IE_OFFSET);
...@@ -526,8 +525,7 @@ static int bcm_iproc_i2c_suspend(struct device *dev) ...@@ -526,8 +525,7 @@ static int bcm_iproc_i2c_suspend(struct device *dev)
static int bcm_iproc_i2c_resume(struct device *dev) static int bcm_iproc_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev);
struct bcm_iproc_i2c_dev *iproc_i2c = platform_get_drvdata(pdev);
int ret; int ret;
u32 val; u32 val;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c/bfin_twi.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/portmux.h> #include <asm/portmux.h>
......
...@@ -826,8 +826,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long ...@@ -826,8 +826,7 @@ static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
*/ */
static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct cdns_i2c *xi2c = dev_get_drvdata(dev);
struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
clk_disable(xi2c->clk); clk_disable(xi2c->clk);
...@@ -844,8 +843,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) ...@@ -844,8 +843,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
*/ */
static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct cdns_i2c *xi2c = dev_get_drvdata(dev);
struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
int ret; int ret;
ret = clk_enable(xi2c->clk); ret = clk_enable(xi2c->clk);
......
This diff is collapsed.
...@@ -413,7 +413,7 @@ static const struct i2c_algorithm cpm_i2c_algo = { ...@@ -413,7 +413,7 @@ static const struct i2c_algorithm cpm_i2c_algo = {
}; };
/* CPM_MAX_READ is also limiting writes according to the code! */ /* CPM_MAX_READ is also limiting writes according to the code! */
static struct i2c_adapter_quirks cpm_i2c_quirks = { static const struct i2c_adapter_quirks cpm_i2c_quirks = {
.max_num_msgs = CPM_MAXBD, .max_num_msgs = CPM_MAXBD,
.max_read_len = CPM_MAX_READ, .max_read_len = CPM_MAX_READ,
.max_write_len = CPM_MAX_READ, .max_write_len = CPM_MAX_READ,
......
...@@ -733,7 +733,7 @@ static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev) ...@@ -733,7 +733,7 @@ static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
} }
#endif #endif
static struct i2c_algorithm i2c_davinci_algo = { static const struct i2c_algorithm i2c_davinci_algo = {
.master_xfer = i2c_davinci_xfer, .master_xfer = i2c_davinci_xfer,
.functionality = i2c_davinci_func, .functionality = i2c_davinci_func,
}; };
...@@ -801,7 +801,7 @@ static int davinci_i2c_probe(struct platform_device *pdev) ...@@ -801,7 +801,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
dev->clk = devm_clk_get(&pdev->dev, NULL); dev->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dev->clk)) if (IS_ERR(dev->clk))
return -ENODEV; return PTR_ERR(dev->clk);
clk_prepare_enable(dev->clk); clk_prepare_enable(dev->clk);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -876,8 +876,7 @@ static int davinci_i2c_remove(struct platform_device *pdev) ...@@ -876,8 +876,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int davinci_i2c_suspend(struct device *dev) static int davinci_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
/* put I2C into reset */ /* put I2C into reset */
davinci_i2c_reset_ctrl(i2c_dev, 0); davinci_i2c_reset_ctrl(i2c_dev, 0);
...@@ -888,8 +887,7 @@ static int davinci_i2c_suspend(struct device *dev) ...@@ -888,8 +887,7 @@ static int davinci_i2c_suspend(struct device *dev)
static int davinci_i2c_resume(struct device *dev) static int davinci_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
clk_prepare_enable(i2c_dev->clk); clk_prepare_enable(i2c_dev->clk);
/* take I2C out of reset */ /* take I2C out of reset */
......
...@@ -439,8 +439,7 @@ static void dw_i2c_plat_complete(struct device *dev) ...@@ -439,8 +439,7 @@ static void dw_i2c_plat_complete(struct device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int dw_i2c_plat_runtime_suspend(struct device *dev) static int dw_i2c_plat_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
i_dev->disable(i_dev); i_dev->disable(i_dev);
i2c_dw_plat_prepare_clk(i_dev, false); i2c_dw_plat_prepare_clk(i_dev, false);
...@@ -450,8 +449,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev) ...@@ -450,8 +449,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
static int dw_i2c_plat_resume(struct device *dev) static int dw_i2c_plat_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
i2c_dw_plat_prepare_clk(i_dev, true); i2c_dw_plat_prepare_clk(i_dev, true);
i_dev->init(i_dev); i_dev->init(i_dev);
......
...@@ -346,7 +346,7 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id) ...@@ -346,7 +346,7 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id)
return IRQ_RETVAL(ret); return IRQ_RETVAL(ret);
} }
static struct i2c_algorithm i2c_dw_algo = { static const struct i2c_algorithm i2c_dw_algo = {
.functionality = i2c_dw_func, .functionality = i2c_dw_func,
.reg_slave = i2c_dw_reg_slave, .reg_slave = i2c_dw_reg_slave,
.unreg_slave = i2c_dw_unreg_slave, .unreg_slave = i2c_dw_unreg_slave,
......
...@@ -803,8 +803,7 @@ static int exynos5_i2c_remove(struct platform_device *pdev) ...@@ -803,8 +803,7 @@ static int exynos5_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int exynos5_i2c_suspend_noirq(struct device *dev) static int exynos5_i2c_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct exynos5_i2c *i2c = dev_get_drvdata(dev);
struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
i2c->suspended = 1; i2c->suspended = 1;
...@@ -815,8 +814,7 @@ static int exynos5_i2c_suspend_noirq(struct device *dev) ...@@ -815,8 +814,7 @@ static int exynos5_i2c_suspend_noirq(struct device *dev)
static int exynos5_i2c_resume_noirq(struct device *dev) static int exynos5_i2c_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct exynos5_i2c *i2c = dev_get_drvdata(dev);
struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
int ret = 0; int ret = 0;
ret = clk_prepare_enable(i2c->clk); ret = clk_prepare_enable(i2c->clk);
......
...@@ -98,8 +98,8 @@ static int of_i2c_gpio_get_pins(struct device_node *np, ...@@ -98,8 +98,8 @@ static int of_i2c_gpio_get_pins(struct device_node *np,
return -EPROBE_DEFER; return -EPROBE_DEFER;
if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) {
pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", pr_err("%pOF: invalid GPIO pins, sda=%d/scl=%d\n",
np->full_name, *sda_pin, *scl_pin); np, *sda_pin, *scl_pin);
return -ENODEV; return -ENODEV;
} }
......
...@@ -505,8 +505,7 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev) ...@@ -505,8 +505,7 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int hix5hd2_i2c_runtime_suspend(struct device *dev) static int hix5hd2_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev);
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
...@@ -515,8 +514,7 @@ static int hix5hd2_i2c_runtime_suspend(struct device *dev) ...@@ -515,8 +514,7 @@ static int hix5hd2_i2c_runtime_suspend(struct device *dev)
static int hix5hd2_i2c_runtime_resume(struct device *dev) static int hix5hd2_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev);
struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev);
clk_prepare_enable(priv->clk); clk_prepare_enable(priv->clk);
hix5hd2_i2c_init(priv); hix5hd2_i2c_init(priv);
......
...@@ -1332,6 +1332,7 @@ static void i801_add_tco(struct i801_priv *priv) ...@@ -1332,6 +1332,7 @@ static void i801_add_tco(struct i801_priv *priv)
u32 tco_base, tco_ctl; u32 tco_base, tco_ctl;
u32 base_addr, ctrl_val; u32 base_addr, ctrl_val;
u64 base64_addr; u64 base64_addr;
u8 hidden;
if (!(priv->features & FEATURE_TCO)) if (!(priv->features & FEATURE_TCO))
return; return;
...@@ -1376,8 +1377,10 @@ static void i801_add_tco(struct i801_priv *priv) ...@@ -1376,8 +1377,10 @@ static void i801_add_tco(struct i801_priv *priv)
devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1); devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
/* Unhide the P2SB device */ /* Unhide the P2SB device, if it is hidden */
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, 0x0); pci_bus_read_config_byte(pci_dev->bus, devfn, 0xe1, &hidden);
if (hidden)
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, 0x0);
pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR, &base_addr); pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR, &base_addr);
base64_addr = base_addr & 0xfffffff0; base64_addr = base_addr & 0xfffffff0;
...@@ -1385,8 +1388,9 @@ static void i801_add_tco(struct i801_priv *priv) ...@@ -1385,8 +1388,9 @@ static void i801_add_tco(struct i801_priv *priv)
pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR + 0x4, &base_addr); pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR + 0x4, &base_addr);
base64_addr |= (u64)base_addr << 32; base64_addr |= (u64)base_addr << 32;
/* Hide the P2SB device */ /* Hide the P2SB device, if it was hidden before */
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, 0x1); if (hidden)
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
spin_unlock(&p2sb_spinlock); spin_unlock(&p2sb_spinlock);
res = &tco_res[ICH_RES_MEM_OFF]; res = &tco_res[ICH_RES_MEM_OFF];
......
...@@ -289,7 +289,7 @@ static const struct i2c_algorithm kempld_i2c_algorithm = { ...@@ -289,7 +289,7 @@ static const struct i2c_algorithm kempld_i2c_algorithm = {
.functionality = kempld_i2c_func, .functionality = kempld_i2c_func,
}; };
static struct i2c_adapter kempld_i2c_adapter = { static const struct i2c_adapter kempld_i2c_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "i2c-kempld", .name = "i2c-kempld",
.class = I2C_CLASS_HWMON | I2C_CLASS_SPD, .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
......
...@@ -457,8 +457,7 @@ static int i2c_lpc2k_remove(struct platform_device *dev) ...@@ -457,8 +457,7 @@ static int i2c_lpc2k_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_lpc2k_suspend(struct device *dev) static int i2c_lpc2k_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
struct lpc2k_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
...@@ -467,8 +466,7 @@ static int i2c_lpc2k_suspend(struct device *dev) ...@@ -467,8 +466,7 @@ static int i2c_lpc2k_suspend(struct device *dev)
static int i2c_lpc2k_resume(struct device *dev) static int i2c_lpc2k_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
struct lpc2k_i2c *i2c = platform_get_drvdata(pdev);
clk_enable(i2c->clk); clk_enable(i2c->clk);
i2c_lpc2k_reset(i2c); i2c_lpc2k_reset(i2c);
......
...@@ -433,7 +433,7 @@ static const struct i2c_algorithm mlxcpld_i2c_algo = { ...@@ -433,7 +433,7 @@ static const struct i2c_algorithm mlxcpld_i2c_algo = {
.functionality = mlxcpld_i2c_func .functionality = mlxcpld_i2c_func
}; };
static struct i2c_adapter_quirks mlxcpld_i2c_quirks = { static const struct i2c_adapter_quirks mlxcpld_i2c_quirks = {
.flags = I2C_AQ_COMB_WRITE_THEN_READ, .flags = I2C_AQ_COMB_WRITE_THEN_READ,
.max_read_len = MLXCPLD_I2C_DATA_REG_SZ - MLXCPLD_I2C_MAX_ADDR_LEN, .max_read_len = MLXCPLD_I2C_DATA_REG_SZ - MLXCPLD_I2C_MAX_ADDR_LEN,
.max_write_len = MLXCPLD_I2C_DATA_REG_SZ, .max_write_len = MLXCPLD_I2C_DATA_REG_SZ,
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#define I2C_FS_START_CON 0x1800 #define I2C_FS_START_CON 0x1800
#define I2C_TIME_CLR_VALUE 0x0000 #define I2C_TIME_CLR_VALUE 0x0000
#define I2C_TIME_DEFAULT_VALUE 0x0003 #define I2C_TIME_DEFAULT_VALUE 0x0003
#define I2C_FS_TIME_INIT_VALUE 0x1303
#define I2C_WRRD_TRANAC_VALUE 0x0002 #define I2C_WRRD_TRANAC_VALUE 0x0002
#define I2C_RD_TRANAC_VALUE 0x0001 #define I2C_RD_TRANAC_VALUE 0x0001
...@@ -154,6 +153,7 @@ struct mtk_i2c { ...@@ -154,6 +153,7 @@ struct mtk_i2c {
bool use_push_pull; /* IO config push-pull mode */ bool use_push_pull; /* IO config push-pull mode */
u16 irq_stat; /* interrupt status */ u16 irq_stat; /* interrupt status */
unsigned int clk_src_div;
unsigned int speed_hz; /* The speed in transfer */ unsigned int speed_hz; /* The speed in transfer */
enum mtk_trans_op op; enum mtk_trans_op op;
u16 timing_reg; u16 timing_reg;
...@@ -172,6 +172,10 @@ static const struct i2c_adapter_quirks mt6577_i2c_quirks = { ...@@ -172,6 +172,10 @@ static const struct i2c_adapter_quirks mt6577_i2c_quirks = {
.max_comb_2nd_msg_len = 31, .max_comb_2nd_msg_len = 31,
}; };
static const struct i2c_adapter_quirks mt7622_i2c_quirks = {
.max_num_msgs = 255,
};
static const struct mtk_i2c_compatible mt6577_compat = { static const struct mtk_i2c_compatible mt6577_compat = {
.quirks = &mt6577_i2c_quirks, .quirks = &mt6577_i2c_quirks,
.pmic_i2c = 0, .pmic_i2c = 0,
...@@ -190,6 +194,15 @@ static const struct mtk_i2c_compatible mt6589_compat = { ...@@ -190,6 +194,15 @@ static const struct mtk_i2c_compatible mt6589_compat = {
.support_33bits = 0, .support_33bits = 0,
}; };
static const struct mtk_i2c_compatible mt7622_compat = {
.quirks = &mt7622_i2c_quirks,
.pmic_i2c = 0,
.dcm = 1,
.auto_restart = 1,
.aux_len_reg = 1,
.support_33bits = 0,
};
static const struct mtk_i2c_compatible mt8173_compat = { static const struct mtk_i2c_compatible mt8173_compat = {
.pmic_i2c = 0, .pmic_i2c = 0,
.dcm = 1, .dcm = 1,
...@@ -201,6 +214,7 @@ static const struct mtk_i2c_compatible mt8173_compat = { ...@@ -201,6 +214,7 @@ static const struct mtk_i2c_compatible mt8173_compat = {
static const struct of_device_id mtk_i2c_of_match[] = { static const struct of_device_id mtk_i2c_of_match[] = {
{ .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
{ .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat },
{ .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat },
{ .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat },
{} {}
}; };
...@@ -285,23 +299,20 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c) ...@@ -285,23 +299,20 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c)
* less than or equal to i2c->speed_hz. The calculation try to get * less than or equal to i2c->speed_hz. The calculation try to get
* sample_cnt and step_cn * sample_cnt and step_cn
*/ */
static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
unsigned int clock_div) unsigned int target_speed,
unsigned int *timing_step_cnt,
unsigned int *timing_sample_cnt)
{ {
unsigned int clk_src;
unsigned int step_cnt; unsigned int step_cnt;
unsigned int sample_cnt; unsigned int sample_cnt;
unsigned int max_step_cnt; unsigned int max_step_cnt;
unsigned int target_speed;
unsigned int base_sample_cnt = MAX_SAMPLE_CNT_DIV; unsigned int base_sample_cnt = MAX_SAMPLE_CNT_DIV;
unsigned int base_step_cnt; unsigned int base_step_cnt;
unsigned int opt_div; unsigned int opt_div;
unsigned int best_mul; unsigned int best_mul;
unsigned int cnt_mul; unsigned int cnt_mul;
clk_src = parent_clk / clock_div;
target_speed = i2c->speed_hz;
if (target_speed > MAX_HS_MODE_SPEED) if (target_speed > MAX_HS_MODE_SPEED)
target_speed = MAX_HS_MODE_SPEED; target_speed = MAX_HS_MODE_SPEED;
...@@ -347,16 +358,48 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, ...@@ -347,16 +358,48 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk,
return -EINVAL; return -EINVAL;
} }
step_cnt--; *timing_step_cnt = step_cnt - 1;
sample_cnt--; *timing_sample_cnt = sample_cnt - 1;
return 0;
}
static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
{
unsigned int clk_src;
unsigned int step_cnt;
unsigned int sample_cnt;
unsigned int target_speed;
int ret;
clk_src = parent_clk / i2c->clk_src_div;
target_speed = i2c->speed_hz;
if (target_speed > MAX_FS_MODE_SPEED) { if (target_speed > MAX_FS_MODE_SPEED) {
/* Set master code speed register */
ret = mtk_i2c_calculate_speed(i2c, clk_src, MAX_FS_MODE_SPEED,
&step_cnt, &sample_cnt);
if (ret < 0)
return ret;
i2c->timing_reg = (sample_cnt << 8) | step_cnt;
/* Set the high speed mode register */ /* Set the high speed mode register */
i2c->timing_reg = I2C_FS_TIME_INIT_VALUE; ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed,
&step_cnt, &sample_cnt);
if (ret < 0)
return ret;
i2c->high_speed_reg = I2C_TIME_DEFAULT_VALUE | i2c->high_speed_reg = I2C_TIME_DEFAULT_VALUE |
(sample_cnt << 12) | (step_cnt << 8); (sample_cnt << 12) | (step_cnt << 8);
} else { } else {
i2c->timing_reg = (sample_cnt << 8) | (step_cnt << 0); ret = mtk_i2c_calculate_speed(i2c, clk_src, target_speed,
&step_cnt, &sample_cnt);
if (ret < 0)
return ret;
i2c->timing_reg = (sample_cnt << 8) | step_cnt;
/* Disable the high speed transaction */ /* Disable the high speed transaction */
i2c->high_speed_reg = I2C_TIME_CLR_VALUE; i2c->high_speed_reg = I2C_TIME_CLR_VALUE;
} }
...@@ -647,8 +690,7 @@ static const struct i2c_algorithm mtk_i2c_algorithm = { ...@@ -647,8 +690,7 @@ static const struct i2c_algorithm mtk_i2c_algorithm = {
.functionality = mtk_i2c_functionality, .functionality = mtk_i2c_functionality,
}; };
static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c)
unsigned int *clk_src_div)
{ {
int ret; int ret;
...@@ -656,11 +698,11 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, ...@@ -656,11 +698,11 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c,
if (ret < 0) if (ret < 0)
i2c->speed_hz = I2C_DEFAULT_SPEED; i2c->speed_hz = I2C_DEFAULT_SPEED;
ret = of_property_read_u32(np, "clock-div", clk_src_div); ret = of_property_read_u32(np, "clock-div", &i2c->clk_src_div);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (*clk_src_div == 0) if (i2c->clk_src_div == 0)
return -EINVAL; return -EINVAL;
i2c->have_pmic = of_property_read_bool(np, "mediatek,have-pmic"); i2c->have_pmic = of_property_read_bool(np, "mediatek,have-pmic");
...@@ -676,7 +718,6 @@ static int mtk_i2c_probe(struct platform_device *pdev) ...@@ -676,7 +718,6 @@ static int mtk_i2c_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
struct mtk_i2c *i2c; struct mtk_i2c *i2c;
struct clk *clk; struct clk *clk;
unsigned int clk_src_div;
struct resource *res; struct resource *res;
int irq; int irq;
...@@ -684,7 +725,7 @@ static int mtk_i2c_probe(struct platform_device *pdev) ...@@ -684,7 +725,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
if (!i2c) if (!i2c)
return -ENOMEM; return -ENOMEM;
ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c, &clk_src_div); ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
...@@ -745,7 +786,7 @@ static int mtk_i2c_probe(struct platform_device *pdev) ...@@ -745,7 +786,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
strlcpy(i2c->adap.name, I2C_DRV_NAME, sizeof(i2c->adap.name)); strlcpy(i2c->adap.name, I2C_DRV_NAME, sizeof(i2c->adap.name));
ret = mtk_i2c_set_speed(i2c, clk_get_rate(clk), clk_src_div); ret = mtk_i2c_set_speed(i2c, clk_get_rate(clk));
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to set the speed.\n"); dev_err(&pdev->dev, "Failed to set the speed.\n");
return -EINVAL; return -EINVAL;
......
...@@ -820,7 +820,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, ...@@ -820,7 +820,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
goto out; goto out;
} }
drv_data->rstc = devm_reset_control_get_optional(dev, NULL); drv_data->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
if (IS_ERR(drv_data->rstc)) { if (IS_ERR(drv_data->rstc)) {
rc = PTR_ERR(drv_data->rstc); rc = PTR_ERR(drv_data->rstc);
goto out; goto out;
...@@ -975,8 +975,7 @@ mv64xxx_i2c_remove(struct platform_device *dev) ...@@ -975,8 +975,7 @@ mv64xxx_i2c_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int mv64xxx_i2c_resume(struct device *dev) static int mv64xxx_i2c_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev);
struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(pdev);
mv64xxx_i2c_hw_init(drv_data); mv64xxx_i2c_hw_init(drv_data);
......
...@@ -1088,7 +1088,7 @@ static struct i2c_vendor_data vendor_db8500 = { ...@@ -1088,7 +1088,7 @@ static struct i2c_vendor_data vendor_db8500 = {
.fifodepth = 32, /* Guessed from TFTR/RFTR = 15 */ .fifodepth = 32, /* Guessed from TFTR/RFTR = 15 */
}; };
static struct amba_id nmk_i2c_ids[] = { static const struct amba_id nmk_i2c_ids[] = {
{ {
.id = 0x00180024, .id = 0x00180024,
.mask = 0x00ffffff, .mask = 0x00ffffff,
......
...@@ -276,7 +276,7 @@ static const struct i2c_algorithm ocores_algorithm = { ...@@ -276,7 +276,7 @@ static const struct i2c_algorithm ocores_algorithm = {
.functionality = ocores_func, .functionality = ocores_func,
}; };
static struct i2c_adapter ocores_adapter = { static const struct i2c_adapter ocores_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "i2c-ocores", .name = "i2c-ocores",
.class = I2C_CLASS_DEPRECATED, .class = I2C_CLASS_DEPRECATED,
......
...@@ -126,7 +126,7 @@ static const struct i2c_algorithm octeon_i2c_algo = { ...@@ -126,7 +126,7 @@ static const struct i2c_algorithm octeon_i2c_algo = {
.functionality = octeon_i2c_functionality, .functionality = octeon_i2c_functionality,
}; };
static struct i2c_adapter octeon_i2c_ops = { static const struct i2c_adapter octeon_i2c_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "OCTEON adapter", .name = "OCTEON adapter",
.algo = &octeon_i2c_algo, .algo = &octeon_i2c_algo,
......
...@@ -204,7 +204,7 @@ static const struct i2c_algorithm i2c_opal_algo = { ...@@ -204,7 +204,7 @@ static const struct i2c_algorithm i2c_opal_algo = {
* For two messages, we basically support simple smbus transactions of a * For two messages, we basically support simple smbus transactions of a
* write-then-anything. * write-then-anything.
*/ */
static struct i2c_adapter_quirks i2c_opal_quirks = { static const struct i2c_adapter_quirks i2c_opal_quirks = {
.flags = I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | I2C_AQ_COMB_SAME_ADDR, .flags = I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | I2C_AQ_COMB_SAME_ADDR,
.max_comb_1st_msg_len = 4, .max_comb_1st_msg_len = 4,
}; };
......
...@@ -577,7 +577,7 @@ static u32 pmcmsptwi_i2c_func(struct i2c_adapter *adapter) ...@@ -577,7 +577,7 @@ static u32 pmcmsptwi_i2c_func(struct i2c_adapter *adapter)
I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL; I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL;
} }
static struct i2c_adapter_quirks pmcmsptwi_i2c_quirks = { static const struct i2c_adapter_quirks pmcmsptwi_i2c_quirks = {
.flags = I2C_AQ_COMB_WRITE_THEN_READ, .flags = I2C_AQ_COMB_WRITE_THEN_READ,
.max_write_len = MSP_MAX_BYTES_PER_RW, .max_write_len = MSP_MAX_BYTES_PER_RW,
.max_read_len = MSP_MAX_BYTES_PER_RW, .max_read_len = MSP_MAX_BYTES_PER_RW,
...@@ -587,7 +587,7 @@ static struct i2c_adapter_quirks pmcmsptwi_i2c_quirks = { ...@@ -587,7 +587,7 @@ static struct i2c_adapter_quirks pmcmsptwi_i2c_quirks = {
/* -- Initialization -- */ /* -- Initialization -- */
static struct i2c_algorithm pmcmsptwi_algo = { static const struct i2c_algorithm pmcmsptwi_algo = {
.master_xfer = pmcmsptwi_master_xfer, .master_xfer = pmcmsptwi_master_xfer,
.functionality = pmcmsptwi_i2c_func, .functionality = pmcmsptwi_i2c_func,
}; };
......
...@@ -590,7 +590,7 @@ static u32 i2c_pnx_func(struct i2c_adapter *adapter) ...@@ -590,7 +590,7 @@ static u32 i2c_pnx_func(struct i2c_adapter *adapter)
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
} }
static struct i2c_algorithm pnx_algorithm = { static const struct i2c_algorithm pnx_algorithm = {
.master_xfer = i2c_pnx_xfer, .master_xfer = i2c_pnx_xfer,
.functionality = i2c_pnx_func, .functionality = i2c_pnx_func,
}; };
......
...@@ -197,7 +197,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = { ...@@ -197,7 +197,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = {
.functionality = i2c_powermac_func, .functionality = i2c_powermac_func,
}; };
static struct i2c_adapter_quirks i2c_powermac_quirks = { static const struct i2c_adapter_quirks i2c_powermac_quirks = {
.max_num_msgs = 1, .max_num_msgs = 1,
}; };
...@@ -234,7 +234,7 @@ static u32 i2c_powermac_get_addr(struct i2c_adapter *adap, ...@@ -234,7 +234,7 @@ static u32 i2c_powermac_get_addr(struct i2c_adapter *adap,
else if (!strcmp(node->name, "deq")) else if (!strcmp(node->name, "deq"))
return 0x34; return 0x34;
dev_warn(&adap->dev, "No i2c address for %s\n", node->full_name); dev_warn(&adap->dev, "No i2c address for %pOF\n", node);
return 0xffffffff; return 0xffffffff;
} }
...@@ -315,8 +315,7 @@ static bool i2c_powermac_get_type(struct i2c_adapter *adap, ...@@ -315,8 +315,7 @@ static bool i2c_powermac_get_type(struct i2c_adapter *adap,
} }
} }
dev_err(&adap->dev, "i2c-powermac: modalias failure" dev_err(&adap->dev, "i2c-powermac: modalias failure on %pOF\n", node);
" on %s\n", node->full_name);
return false; return false;
} }
...@@ -348,8 +347,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap, ...@@ -348,8 +347,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap,
if (!pmac_i2c_match_adapter(node, adap)) if (!pmac_i2c_match_adapter(node, adap))
continue; continue;
dev_dbg(&adap->dev, "i2c-powermac: register %s\n", dev_dbg(&adap->dev, "i2c-powermac: register %pOF\n", node);
node->full_name);
/* /*
* Keep track of some device existence to handle * Keep track of some device existence to handle
...@@ -372,7 +370,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap, ...@@ -372,7 +370,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap,
newdev = i2c_new_device(adap, &info); newdev = i2c_new_device(adap, &info);
if (!newdev) { if (!newdev) {
dev_err(&adap->dev, "i2c-powermac: Failure to register" dev_err(&adap->dev, "i2c-powermac: Failure to register"
" %s\n", node->full_name); " %pOF\n", node);
of_node_put(node); of_node_put(node);
/* We do not dispose of the interrupt mapping on /* We do not dispose of the interrupt mapping on
* purpose. It's not necessary (interrupt cannot be * purpose. It's not necessary (interrupt cannot be
......
...@@ -175,7 +175,7 @@ static u32 puv3_i2c_func(struct i2c_adapter *adapter) ...@@ -175,7 +175,7 @@ static u32 puv3_i2c_func(struct i2c_adapter *adapter)
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
} }
static struct i2c_algorithm puv3_i2c_algorithm = { static const struct i2c_algorithm puv3_i2c_algorithm = {
.master_xfer = puv3_i2c_xfer, .master_xfer = puv3_i2c_xfer,
.functionality = puv3_i2c_func, .functionality = puv3_i2c_func,
}; };
......
...@@ -1346,8 +1346,7 @@ static int i2c_pxa_remove(struct platform_device *dev) ...@@ -1346,8 +1346,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_pxa_suspend_noirq(struct device *dev) static int i2c_pxa_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct pxa_i2c *i2c = dev_get_drvdata(dev);
struct pxa_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
...@@ -1356,8 +1355,7 @@ static int i2c_pxa_suspend_noirq(struct device *dev) ...@@ -1356,8 +1355,7 @@ static int i2c_pxa_suspend_noirq(struct device *dev)
static int i2c_pxa_resume_noirq(struct device *dev) static int i2c_pxa_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct pxa_i2c *i2c = dev_get_drvdata(dev);
struct pxa_i2c *i2c = platform_get_drvdata(pdev);
clk_enable(i2c->clk); clk_enable(i2c->clk);
i2c_pxa_reset(i2c); i2c_pxa_reset(i2c);
......
...@@ -1396,7 +1396,7 @@ static const struct i2c_algorithm qup_i2c_algo_v2 = { ...@@ -1396,7 +1396,7 @@ static const struct i2c_algorithm qup_i2c_algo_v2 = {
* the end of the read, the length of the read is specified as one byte * the end of the read, the length of the read is specified as one byte
* which limits the possible read to 256 (QUP_READ_LIMIT) bytes. * which limits the possible read to 256 (QUP_READ_LIMIT) bytes.
*/ */
static struct i2c_adapter_quirks qup_i2c_quirks = { static const struct i2c_adapter_quirks qup_i2c_quirks = {
.max_read_len = QUP_READ_LIMIT, .max_read_len = QUP_READ_LIMIT,
}; };
......
...@@ -625,9 +625,8 @@ static struct dma_chan *rcar_i2c_request_dma_chan(struct device *dev, ...@@ -625,9 +625,8 @@ static struct dma_chan *rcar_i2c_request_dma_chan(struct device *dev,
chan = dma_request_chan(dev, chan_name); chan = dma_request_chan(dev, chan_name);
if (IS_ERR(chan)) { if (IS_ERR(chan)) {
ret = PTR_ERR(chan); dev_dbg(dev, "request_channel failed for %s (%ld)\n",
dev_dbg(dev, "request_channel failed for %s (%d)\n", chan_name, PTR_ERR(chan));
chan_name, ret);
return chan; return chan;
} }
......
...@@ -1131,6 +1131,11 @@ static const struct i2c_algorithm rk3x_i2c_algorithm = { ...@@ -1131,6 +1131,11 @@ static const struct i2c_algorithm rk3x_i2c_algorithm = {
.functionality = rk3x_i2c_func, .functionality = rk3x_i2c_func,
}; };
static const struct rk3x_i2c_soc_data rv1108_soc_data = {
.grf_offset = -1,
.calc_timings = rk3x_i2c_v1_calc_timings,
};
static const struct rk3x_i2c_soc_data rk3066_soc_data = { static const struct rk3x_i2c_soc_data rk3066_soc_data = {
.grf_offset = 0x154, .grf_offset = 0x154,
.calc_timings = rk3x_i2c_v0_calc_timings, .calc_timings = rk3x_i2c_v0_calc_timings,
...@@ -1157,6 +1162,10 @@ static const struct rk3x_i2c_soc_data rk3399_soc_data = { ...@@ -1157,6 +1162,10 @@ static const struct rk3x_i2c_soc_data rk3399_soc_data = {
}; };
static const struct of_device_id rk3x_i2c_match[] = { static const struct of_device_id rk3x_i2c_match[] = {
{
.compatible = "rockchip,rv1108-i2c",
.data = (void *)&rv1108_soc_data
},
{ {
.compatible = "rockchip,rk3066-i2c", .compatible = "rockchip,rk3066-i2c",
.data = (void *)&rk3066_soc_data .data = (void *)&rk3066_soc_data
......
...@@ -1246,8 +1246,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) ...@@ -1246,8 +1246,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int s3c24xx_i2c_suspend_noirq(struct device *dev) static int s3c24xx_i2c_suspend_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
i2c->suspended = 1; i2c->suspended = 1;
...@@ -1259,8 +1258,7 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev) ...@@ -1259,8 +1258,7 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)
static int s3c24xx_i2c_resume_noirq(struct device *dev) static int s3c24xx_i2c_resume_noirq(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
int ret; int ret;
if (!IS_ERR(i2c->sysreg)) if (!IS_ERR(i2c->sysreg))
......
...@@ -561,8 +561,8 @@ static struct dma_chan *sh_mobile_i2c_request_dma_chan(struct device *dev, ...@@ -561,8 +561,8 @@ static struct dma_chan *sh_mobile_i2c_request_dma_chan(struct device *dev,
chan = dma_request_slave_channel_reason(dev, chan_name); chan = dma_request_slave_channel_reason(dev, chan_name);
if (IS_ERR(chan)) { if (IS_ERR(chan)) {
ret = PTR_ERR(chan); dev_dbg(dev, "request_channel failed for %s (%ld)\n", chan_name,
dev_dbg(dev, "request_channel failed for %s (%d)\n", chan_name, ret); PTR_ERR(chan));
return chan; return chan;
} }
......
...@@ -421,8 +421,7 @@ static int i2c_sirfsoc_remove(struct platform_device *pdev) ...@@ -421,8 +421,7 @@ static int i2c_sirfsoc_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int i2c_sirfsoc_suspend(struct device *dev) static int i2c_sirfsoc_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct i2c_adapter *adapter = dev_get_drvdata(dev);
struct i2c_adapter *adapter = platform_get_drvdata(pdev);
struct sirfsoc_i2c *siic = adapter->algo_data; struct sirfsoc_i2c *siic = adapter->algo_data;
clk_enable(siic->clk); clk_enable(siic->clk);
...@@ -434,8 +433,7 @@ static int i2c_sirfsoc_suspend(struct device *dev) ...@@ -434,8 +433,7 @@ static int i2c_sirfsoc_suspend(struct device *dev)
static int i2c_sirfsoc_resume(struct device *dev) static int i2c_sirfsoc_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct i2c_adapter *adapter = dev_get_drvdata(dev);
struct i2c_adapter *adapter = platform_get_drvdata(pdev);
struct sirfsoc_i2c *siic = adapter->algo_data; struct sirfsoc_i2c *siic = adapter->algo_data;
clk_enable(siic->clk); clk_enable(siic->clk);
......
This diff is collapsed.
...@@ -745,8 +745,7 @@ static int st_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -745,8 +745,7 @@ static int st_i2c_xfer(struct i2c_adapter *i2c_adap,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int st_i2c_suspend(struct device *dev) static int st_i2c_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct st_i2c_dev *i2c_dev = dev_get_drvdata(dev);
struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
if (i2c_dev->busy) if (i2c_dev->busy)
return -EBUSY; return -EBUSY;
......
...@@ -751,7 +751,7 @@ static u32 stm32f4_i2c_func(struct i2c_adapter *adap) ...@@ -751,7 +751,7 @@ static u32 stm32f4_i2c_func(struct i2c_adapter *adap)
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
} }
static struct i2c_algorithm stm32f4_i2c_algo = { static const struct i2c_algorithm stm32f4_i2c_algo = {
.master_xfer = stm32f4_i2c_xfer, .master_xfer = stm32f4_i2c_xfer,
.functionality = stm32f4_i2c_func, .functionality = stm32f4_i2c_func,
}; };
...@@ -798,7 +798,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) ...@@ -798,7 +798,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev)
return ret; return ret;
} }
rst = devm_reset_control_get(&pdev->dev, NULL); rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
dev_err(&pdev->dev, "Error: Missing controller reset\n"); dev_err(&pdev->dev, "Error: Missing controller reset\n");
ret = PTR_ERR(rst); ret = PTR_ERR(rst);
......
...@@ -223,8 +223,8 @@ static int p2wi_probe(struct platform_device *pdev) ...@@ -223,8 +223,8 @@ static int p2wi_probe(struct platform_device *pdev)
if (childnp) { if (childnp) {
ret = of_property_read_u32(childnp, "reg", &slave_addr); ret = of_property_read_u32(childnp, "reg", &slave_addr);
if (ret) { if (ret) {
dev_err(dev, "invalid slave address on node %s\n", dev_err(dev, "invalid slave address on node %pOF\n",
childnp->full_name); childnp);
return -EINVAL; return -EINVAL;
} }
...@@ -258,7 +258,7 @@ static int p2wi_probe(struct platform_device *pdev) ...@@ -258,7 +258,7 @@ static int p2wi_probe(struct platform_device *pdev)
parent_clk_freq = clk_get_rate(p2wi->clk); parent_clk_freq = clk_get_rate(p2wi->clk);
p2wi->rstc = devm_reset_control_get(dev, NULL); p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(p2wi->rstc)) { if (IS_ERR(p2wi->rstc)) {
ret = PTR_ERR(p2wi->rstc); ret = PTR_ERR(p2wi->rstc);
dev_err(dev, "failed to retrieve reset controller: %d\n", ret); dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
......
...@@ -291,7 +291,7 @@ static void taos_disconnect(struct serio *serio) ...@@ -291,7 +291,7 @@ static void taos_disconnect(struct serio *serio)
dev_info(&serio->dev, "Disconnected from TAOS EVM\n"); dev_info(&serio->dev, "Disconnected from TAOS EVM\n");
} }
static struct serio_device_id taos_serio_ids[] = { static const struct serio_device_id taos_serio_ids[] = {
{ {
.type = SERIO_RS232, .type = SERIO_RS232,
.proto = SERIO_TAOSEVM, .proto = SERIO_TAOSEVM,
......
...@@ -793,7 +793,7 @@ static const struct i2c_algorithm tegra_i2c_algo = { ...@@ -793,7 +793,7 @@ static const struct i2c_algorithm tegra_i2c_algo = {
}; };
/* payload size is only 12 bit */ /* payload size is only 12 bit */
static struct i2c_adapter_quirks tegra_i2c_quirks = { static const struct i2c_adapter_quirks tegra_i2c_quirks = {
.max_read_len = 4096, .max_read_len = 4096,
.max_write_len = 4096, .max_write_len = 4096,
}; };
...@@ -911,7 +911,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ...@@ -911,7 +911,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
i2c_dev->cont_id = pdev->id; i2c_dev->cont_id = pdev->id;
i2c_dev->dev = &pdev->dev; i2c_dev->dev = &pdev->dev;
i2c_dev->rst = devm_reset_control_get(&pdev->dev, "i2c"); i2c_dev->rst = devm_reset_control_get_exclusive(&pdev->dev, "i2c");
if (IS_ERR(i2c_dev->rst)) { if (IS_ERR(i2c_dev->rst)) {
dev_err(&pdev->dev, "missing controller reset\n"); dev_err(&pdev->dev, "missing controller reset\n");
return PTR_ERR(i2c_dev->rst); return PTR_ERR(i2c_dev->rst);
......
...@@ -75,7 +75,7 @@ static const struct i2c_algorithm thunderx_i2c_algo = { ...@@ -75,7 +75,7 @@ static const struct i2c_algorithm thunderx_i2c_algo = {
.functionality = thunderx_i2c_functionality, .functionality = thunderx_i2c_functionality,
}; };
static struct i2c_adapter thunderx_i2c_ops = { static const struct i2c_adapter thunderx_i2c_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ThunderX adapter", .name = "ThunderX adapter",
.algo = &thunderx_i2c_algo, .algo = &thunderx_i2c_algo,
......
...@@ -97,6 +97,7 @@ struct uniphier_fi2c_priv { ...@@ -97,6 +97,7 @@ struct uniphier_fi2c_priv {
int error; int error;
unsigned int flags; unsigned int flags;
unsigned int busy_cnt; unsigned int busy_cnt;
unsigned int clk_cycle;
}; };
static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv, static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv,
...@@ -461,9 +462,9 @@ static struct i2c_bus_recovery_info uniphier_fi2c_bus_recovery_info = { ...@@ -461,9 +462,9 @@ static struct i2c_bus_recovery_info uniphier_fi2c_bus_recovery_info = {
.unprepare_recovery = uniphier_fi2c_unprepare_recovery, .unprepare_recovery = uniphier_fi2c_unprepare_recovery,
}; };
static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv, static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv)
u32 bus_speed, unsigned long clk_rate)
{ {
unsigned int cyc = priv->clk_cycle;
u32 tmp; u32 tmp;
tmp = readl(priv->membase + UNIPHIER_FI2C_CR); tmp = readl(priv->membase + UNIPHIER_FI2C_CR);
...@@ -472,12 +473,10 @@ static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv, ...@@ -472,12 +473,10 @@ static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv,
uniphier_fi2c_reset(priv); uniphier_fi2c_reset(priv);
tmp = clk_rate / bus_speed; writel(cyc, priv->membase + UNIPHIER_FI2C_CYC);
writel(cyc / 2, priv->membase + UNIPHIER_FI2C_LCTL);
writel(tmp, priv->membase + UNIPHIER_FI2C_CYC); writel(cyc / 2, priv->membase + UNIPHIER_FI2C_SSUT);
writel(tmp / 2, priv->membase + UNIPHIER_FI2C_LCTL); writel(cyc / 16, priv->membase + UNIPHIER_FI2C_DSUT);
writel(tmp / 2, priv->membase + UNIPHIER_FI2C_SSUT);
writel(tmp / 16, priv->membase + UNIPHIER_FI2C_DSUT);
uniphier_fi2c_prepare_operation(priv); uniphier_fi2c_prepare_operation(priv);
} }
...@@ -531,6 +530,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) ...@@ -531,6 +530,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
goto disable_clk; goto disable_clk;
} }
priv->clk_cycle = clk_rate / bus_speed;
init_completion(&priv->comp); init_completion(&priv->comp);
priv->adap.owner = THIS_MODULE; priv->adap.owner = THIS_MODULE;
priv->adap.algo = &uniphier_fi2c_algo; priv->adap.algo = &uniphier_fi2c_algo;
...@@ -541,7 +541,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) ...@@ -541,7 +541,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
i2c_set_adapdata(&priv->adap, priv); i2c_set_adapdata(&priv->adap, priv);
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
uniphier_fi2c_hw_init(priv, bus_speed, clk_rate); uniphier_fi2c_hw_init(priv);
ret = devm_request_irq(dev, irq, uniphier_fi2c_interrupt, 0, ret = devm_request_irq(dev, irq, uniphier_fi2c_interrupt, 0,
pdev->name, priv); pdev->name, priv);
...@@ -568,6 +568,33 @@ static int uniphier_fi2c_remove(struct platform_device *pdev) ...@@ -568,6 +568,33 @@ static int uniphier_fi2c_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __maybe_unused uniphier_fi2c_suspend(struct device *dev)
{
struct uniphier_fi2c_priv *priv = dev_get_drvdata(dev);
clk_disable_unprepare(priv->clk);
return 0;
}
static int __maybe_unused uniphier_fi2c_resume(struct device *dev)
{
struct uniphier_fi2c_priv *priv = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;
uniphier_fi2c_hw_init(priv);
return 0;
}
static const struct dev_pm_ops uniphier_fi2c_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(uniphier_fi2c_suspend, uniphier_fi2c_resume)
};
static const struct of_device_id uniphier_fi2c_match[] = { static const struct of_device_id uniphier_fi2c_match[] = {
{ .compatible = "socionext,uniphier-fi2c" }, { .compatible = "socionext,uniphier-fi2c" },
{ /* sentinel */ } { /* sentinel */ }
...@@ -580,6 +607,7 @@ static struct platform_driver uniphier_fi2c_drv = { ...@@ -580,6 +607,7 @@ static struct platform_driver uniphier_fi2c_drv = {
.driver = { .driver = {
.name = "uniphier-fi2c", .name = "uniphier-fi2c",
.of_match_table = uniphier_fi2c_match, .of_match_table = uniphier_fi2c_match,
.pm = &uniphier_fi2c_pm_ops,
}, },
}; };
module_platform_driver(uniphier_fi2c_drv); module_platform_driver(uniphier_fi2c_drv);
......
...@@ -53,6 +53,7 @@ struct uniphier_i2c_priv { ...@@ -53,6 +53,7 @@ struct uniphier_i2c_priv {
void __iomem *membase; void __iomem *membase;
struct clk *clk; struct clk *clk;
unsigned int busy_cnt; unsigned int busy_cnt;
unsigned int clk_cycle;
}; };
static irqreturn_t uniphier_i2c_interrupt(int irq, void *dev_id) static irqreturn_t uniphier_i2c_interrupt(int irq, void *dev_id)
...@@ -316,13 +317,13 @@ static struct i2c_bus_recovery_info uniphier_i2c_bus_recovery_info = { ...@@ -316,13 +317,13 @@ static struct i2c_bus_recovery_info uniphier_i2c_bus_recovery_info = {
.unprepare_recovery = uniphier_i2c_unprepare_recovery, .unprepare_recovery = uniphier_i2c_unprepare_recovery,
}; };
static void uniphier_i2c_hw_init(struct uniphier_i2c_priv *priv, static void uniphier_i2c_hw_init(struct uniphier_i2c_priv *priv)
u32 bus_speed, unsigned long clk_rate)
{ {
unsigned int cyc = priv->clk_cycle;
uniphier_i2c_reset(priv, true); uniphier_i2c_reset(priv, true);
writel((clk_rate / bus_speed / 2 << 16) | (clk_rate / bus_speed), writel((cyc / 2 << 16) | cyc, priv->membase + UNIPHIER_I2C_CLK);
priv->membase + UNIPHIER_I2C_CLK);
uniphier_i2c_reset(priv, false); uniphier_i2c_reset(priv, false);
} }
...@@ -376,6 +377,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev) ...@@ -376,6 +377,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
goto disable_clk; goto disable_clk;
} }
priv->clk_cycle = clk_rate / bus_speed;
init_completion(&priv->comp); init_completion(&priv->comp);
priv->adap.owner = THIS_MODULE; priv->adap.owner = THIS_MODULE;
priv->adap.algo = &uniphier_i2c_algo; priv->adap.algo = &uniphier_i2c_algo;
...@@ -386,7 +388,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev) ...@@ -386,7 +388,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(&priv->adap, priv); i2c_set_adapdata(&priv->adap, priv);
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
uniphier_i2c_hw_init(priv, bus_speed, clk_rate); uniphier_i2c_hw_init(priv);
ret = devm_request_irq(dev, irq, uniphier_i2c_interrupt, 0, pdev->name, ret = devm_request_irq(dev, irq, uniphier_i2c_interrupt, 0, pdev->name,
priv); priv);
...@@ -413,6 +415,33 @@ static int uniphier_i2c_remove(struct platform_device *pdev) ...@@ -413,6 +415,33 @@ static int uniphier_i2c_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __maybe_unused uniphier_i2c_suspend(struct device *dev)
{
struct uniphier_i2c_priv *priv = dev_get_drvdata(dev);
clk_disable_unprepare(priv->clk);
return 0;
}
static int __maybe_unused uniphier_i2c_resume(struct device *dev)
{
struct uniphier_i2c_priv *priv = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;
uniphier_i2c_hw_init(priv);
return 0;
}
static const struct dev_pm_ops uniphier_i2c_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(uniphier_i2c_suspend, uniphier_i2c_resume)
};
static const struct of_device_id uniphier_i2c_match[] = { static const struct of_device_id uniphier_i2c_match[] = {
{ .compatible = "socionext,uniphier-i2c" }, { .compatible = "socionext,uniphier-i2c" },
{ /* sentinel */ } { /* sentinel */ }
...@@ -425,6 +454,7 @@ static struct platform_driver uniphier_i2c_drv = { ...@@ -425,6 +454,7 @@ static struct platform_driver uniphier_i2c_drv = {
.driver = { .driver = {
.name = "uniphier-i2c", .name = "uniphier-i2c",
.of_match_table = uniphier_i2c_match, .of_match_table = uniphier_i2c_match,
.pm = &uniphier_i2c_pm_ops,
}, },
}; };
module_platform_driver(uniphier_i2c_drv); module_platform_driver(uniphier_i2c_drv);
......
...@@ -55,7 +55,7 @@ static int i2c_versatile_getscl(void *data) ...@@ -55,7 +55,7 @@ static int i2c_versatile_getscl(void *data)
return !!(readl(i2c->base + I2C_CONTROL) & SCL); return !!(readl(i2c->base + I2C_CONTROL) & SCL);
} }
static struct i2c_algo_bit_data i2c_versatile_algo = { static const struct i2c_algo_bit_data i2c_versatile_algo = {
.setsda = i2c_versatile_setsda, .setsda = i2c_versatile_setsda,
.setscl = i2c_versatile_setscl, .setscl = i2c_versatile_setscl,
.getsda = i2c_versatile_getsda, .getsda = i2c_versatile_getsda,
......
...@@ -721,7 +721,7 @@ static const struct i2c_algorithm xiic_algorithm = { ...@@ -721,7 +721,7 @@ static const struct i2c_algorithm xiic_algorithm = {
.functionality = xiic_func, .functionality = xiic_func,
}; };
static struct i2c_adapter xiic_adapter = { static const struct i2c_adapter xiic_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = DRIVER_NAME, .name = DRIVER_NAME,
.class = I2C_CLASS_DEPRECATED, .class = I2C_CLASS_DEPRECATED,
...@@ -853,8 +853,7 @@ MODULE_DEVICE_TABLE(of, xiic_of_match); ...@@ -853,8 +853,7 @@ MODULE_DEVICE_TABLE(of, xiic_of_match);
static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct xiic_i2c *i2c = dev_get_drvdata(dev);
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
clk_disable(i2c->clk); clk_disable(i2c->clk);
...@@ -863,8 +862,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev) ...@@ -863,8 +862,7 @@ static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev) static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct xiic_i2c *i2c = dev_get_drvdata(dev);
struct xiic_i2c *i2c = platform_get_drvdata(pdev);
int ret; int ret;
ret = clk_enable(i2c->clk); ret = clk_enable(i2c->clk);
......
...@@ -32,18 +32,17 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, ...@@ -32,18 +32,17 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
u32 addr; u32 addr;
int len; int len;
dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name); dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node);
if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) { if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
dev_err(&adap->dev, "of_i2c: modalias failure on %s\n", dev_err(&adap->dev, "of_i2c: modalias failure on %pOF\n",
node->full_name); node);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
addr_be = of_get_property(node, "reg", &len); addr_be = of_get_property(node, "reg", &len);
if (!addr_be || (len < sizeof(*addr_be))) { if (!addr_be || (len < sizeof(*addr_be))) {
dev_err(&adap->dev, "of_i2c: invalid reg on %s\n", dev_err(&adap->dev, "of_i2c: invalid reg on %pOF\n", node);
node->full_name);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -59,8 +58,8 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, ...@@ -59,8 +58,8 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
} }
if (i2c_check_addr_validity(addr, info.flags)) { if (i2c_check_addr_validity(addr, info.flags)) {
dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n", dev_err(&adap->dev, "of_i2c: invalid addr=%x on %pOF\n",
addr, node->full_name); addr, node);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -76,8 +75,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap, ...@@ -76,8 +75,7 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
result = i2c_new_device(adap, &info); result = i2c_new_device(adap, &info);
if (result == NULL) { if (result == NULL) {
dev_err(&adap->dev, "of_i2c: Failure registering %s\n", dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node);
node->full_name);
of_node_put(node); of_node_put(node);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -106,8 +104,8 @@ void of_i2c_register_devices(struct i2c_adapter *adap) ...@@ -106,8 +104,8 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
client = of_i2c_register_device(adap, node); client = of_i2c_register_device(adap, node);
if (IS_ERR(client)) { if (IS_ERR(client)) {
dev_warn(&adap->dev, dev_warn(&adap->dev,
"Failed to create I2C device for %s\n", "Failed to create I2C device for %pOF\n",
node->full_name); node);
of_node_clear_flag(node, OF_POPULATED); of_node_clear_flag(node, OF_POPULATED);
} }
} }
...@@ -243,8 +241,8 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, ...@@ -243,8 +241,8 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
put_device(&adap->dev); put_device(&adap->dev);
if (IS_ERR(client)) { if (IS_ERR(client)) {
dev_err(&adap->dev, "failed to create client for '%s'\n", dev_err(&adap->dev, "failed to create client for '%pOF'\n",
rd->dn->full_name); rd->dn);
of_node_clear_flag(rd->dn, OF_POPULATED); of_node_clear_flag(rd->dn, OF_POPULATED);
return notifier_from_errno(PTR_ERR(client)); return notifier_from_errno(PTR_ERR(client));
} }
......
...@@ -8,7 +8,7 @@ menu "Multiplexer I2C Chip support" ...@@ -8,7 +8,7 @@ menu "Multiplexer I2C Chip support"
config I2C_ARB_GPIO_CHALLENGE config I2C_ARB_GPIO_CHALLENGE
tristate "GPIO-based I2C arbitration" tristate "GPIO-based I2C arbitration"
depends on GPIOLIB || COMPILE_TEST depends on GPIOLIB || COMPILE_TEST
depends on OF depends on OF || COMPILE_TEST
help help
If you say yes to this option, support will be included for an If you say yes to this option, support will be included for an
I2C multimaster arbitration scheme using GPIOs and a challenge & I2C multimaster arbitration scheme using GPIOs and a challenge &
...@@ -76,6 +76,7 @@ config I2C_MUX_PCA954x ...@@ -76,6 +76,7 @@ config I2C_MUX_PCA954x
config I2C_MUX_PINCTRL config I2C_MUX_PINCTRL
tristate "pinctrl-based I2C multiplexer" tristate "pinctrl-based I2C multiplexer"
depends on PINCTRL depends on PINCTRL
depends on OF || COMPILE_TEST
help help
If you say yes to this option, support will be included for an I2C If you say yes to this option, support will be included for an I2C
multiplexer that uses the pinctrl subsystem, i.e. pin multiplexing. multiplexer that uses the pinctrl subsystem, i.e. pin multiplexing.
......
...@@ -167,8 +167,8 @@ static ssize_t available_masters_show(struct device *dev, ...@@ -167,8 +167,8 @@ static ssize_t available_masters_show(struct device *dev,
int count = 0, i; int count = 0, i;
for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++) for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++)
count += scnprintf(buf + count, PAGE_SIZE - count, "%d:%s%c", count += scnprintf(buf + count, PAGE_SIZE - count, "%d:%pOF%c",
i, priv->chan[i].parent_np->full_name, i, priv->chan[i].parent_np,
i == priv->num_chan - 1 ? '\n' : ' '); i == priv->num_chan - 1 ? '\n' : ' ');
return count; return count;
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_data/x86/mlxcpld.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c/mlxcpld.h>
#define CPLD_MUX_MAX_NCHANS 8 #define CPLD_MUX_MAX_NCHANS 8
......
...@@ -16,15 +16,14 @@ ...@@ -16,15 +16,14 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <linux/jiffies.h>
#include <linux/i2c/pca954x.h> #include <linux/module.h>
#include <linux/platform_data/pca954x.h>
#include <linux/slab.h>
/* /*
* The PCA9541 is a bus master selector. It supports two I2C masters connected * The PCA9541 is a bus master selector. It supports two I2C masters connected
......
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <linux/i2c/pca954x.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/platform_data/pca954x.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
......
...@@ -20,17 +20,14 @@ ...@@ -20,17 +20,14 @@
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/i2c-mux-pinctrl.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include "../../pinctrl/core.h" #include "../../pinctrl/core.h"
struct i2c_mux_pinctrl { struct i2c_mux_pinctrl {
struct i2c_mux_pinctrl_platform_data *pdata;
struct pinctrl *pinctrl; struct pinctrl *pinctrl;
struct pinctrl_state **states; struct pinctrl_state **states;
struct pinctrl_state *state_idle;
}; };
static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan) static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan)
...@@ -42,85 +39,9 @@ static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan) ...@@ -42,85 +39,9 @@ static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan)
static int i2c_mux_pinctrl_deselect(struct i2c_mux_core *muxc, u32 chan) static int i2c_mux_pinctrl_deselect(struct i2c_mux_core *muxc, u32 chan)
{ {
struct i2c_mux_pinctrl *mux = i2c_mux_priv(muxc); return i2c_mux_pinctrl_select(muxc, muxc->num_adapters);
return pinctrl_select_state(mux->pinctrl, mux->state_idle);
} }
#ifdef CONFIG_OF
static int i2c_mux_pinctrl_parse_dt(struct i2c_mux_pinctrl *mux,
struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
int num_names, i, ret;
struct device_node *adapter_np;
struct i2c_adapter *adapter;
if (!np)
return 0;
mux->pdata = devm_kzalloc(&pdev->dev, sizeof(*mux->pdata), GFP_KERNEL);
if (!mux->pdata)
return -ENOMEM;
num_names = of_property_count_strings(np, "pinctrl-names");
if (num_names < 0) {
dev_err(&pdev->dev, "Cannot parse pinctrl-names: %d\n",
num_names);
return num_names;
}
mux->pdata->pinctrl_states = devm_kzalloc(&pdev->dev,
sizeof(*mux->pdata->pinctrl_states) * num_names,
GFP_KERNEL);
if (!mux->pdata->pinctrl_states)
return -ENOMEM;
for (i = 0; i < num_names; i++) {
ret = of_property_read_string_index(np, "pinctrl-names", i,
&mux->pdata->pinctrl_states[mux->pdata->bus_count]);
if (ret < 0) {
dev_err(&pdev->dev, "Cannot parse pinctrl-names: %d\n",
ret);
return ret;
}
if (!strcmp(mux->pdata->pinctrl_states[mux->pdata->bus_count],
"idle")) {
if (i != num_names - 1) {
dev_err(&pdev->dev,
"idle state must be last\n");
return -EINVAL;
}
mux->pdata->pinctrl_state_idle = "idle";
} else {
mux->pdata->bus_count++;
}
}
adapter_np = of_parse_phandle(np, "i2c-parent", 0);
if (!adapter_np) {
dev_err(&pdev->dev, "Cannot parse i2c-parent\n");
return -ENODEV;
}
adapter = of_find_i2c_adapter_by_node(adapter_np);
of_node_put(adapter_np);
if (!adapter) {
dev_err(&pdev->dev, "Cannot find parent bus\n");
return -EPROBE_DEFER;
}
mux->pdata->parent_bus_num = i2c_adapter_id(adapter);
put_device(&adapter->dev);
return 0;
}
#else
static inline int i2c_mux_pinctrl_parse_dt(struct i2c_mux_pinctrl *mux,
struct platform_device *pdev)
{
return 0;
}
#endif
static struct i2c_adapter *i2c_mux_pinctrl_root_adapter( static struct i2c_adapter *i2c_mux_pinctrl_root_adapter(
struct pinctrl_state *state) struct pinctrl_state *state)
{ {
...@@ -141,110 +62,108 @@ static struct i2c_adapter *i2c_mux_pinctrl_root_adapter( ...@@ -141,110 +62,108 @@ static struct i2c_adapter *i2c_mux_pinctrl_root_adapter(
return root; return root;
} }
static struct i2c_adapter *i2c_mux_pinctrl_parent_adapter(struct device *dev)
{
struct device_node *np = dev->of_node;
struct device_node *parent_np;
struct i2c_adapter *parent;
parent_np = of_parse_phandle(np, "i2c-parent", 0);
if (!parent_np) {
dev_err(dev, "Cannot parse i2c-parent\n");
return ERR_PTR(-ENODEV);
}
parent = of_find_i2c_adapter_by_node(parent_np);
of_node_put(parent_np);
if (!parent)
return ERR_PTR(-EPROBE_DEFER);
return parent;
}
static int i2c_mux_pinctrl_probe(struct platform_device *pdev) static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct i2c_mux_core *muxc; struct i2c_mux_core *muxc;
struct i2c_mux_pinctrl *mux; struct i2c_mux_pinctrl *mux;
struct i2c_adapter *parent;
struct i2c_adapter *root; struct i2c_adapter *root;
int i, ret; int num_names, i, ret;
const char *name;
mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL);
if (!mux) {
ret = -ENOMEM;
goto err;
}
mux->pdata = dev_get_platdata(&pdev->dev); num_names = of_property_count_strings(np, "pinctrl-names");
if (!mux->pdata) { if (num_names < 0) {
ret = i2c_mux_pinctrl_parse_dt(mux, pdev); dev_err(dev, "Cannot parse pinctrl-names: %d\n",
if (ret < 0) num_names);
goto err; return num_names;
}
if (!mux->pdata) {
dev_err(&pdev->dev, "Missing platform data\n");
ret = -ENODEV;
goto err;
} }
mux->states = devm_kzalloc(&pdev->dev, parent = i2c_mux_pinctrl_parent_adapter(dev);
sizeof(*mux->states) * mux->pdata->bus_count, if (IS_ERR(parent))
GFP_KERNEL); return PTR_ERR(parent);
if (!mux->states) {
dev_err(&pdev->dev, "Cannot allocate states\n");
ret = -ENOMEM;
goto err;
}
muxc = i2c_mux_alloc(NULL, &pdev->dev, mux->pdata->bus_count, 0, 0, muxc = i2c_mux_alloc(parent, dev, num_names,
i2c_mux_pinctrl_select, NULL); sizeof(*mux) + num_names * sizeof(*mux->states),
0, i2c_mux_pinctrl_select, NULL);
if (!muxc) { if (!muxc) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err_put_parent;
} }
muxc->priv = mux; mux = i2c_mux_priv(muxc);
mux->states = (struct pinctrl_state **)(mux + 1);
platform_set_drvdata(pdev, muxc); platform_set_drvdata(pdev, muxc);
mux->pinctrl = devm_pinctrl_get(&pdev->dev); mux->pinctrl = devm_pinctrl_get(dev);
if (IS_ERR(mux->pinctrl)) { if (IS_ERR(mux->pinctrl)) {
ret = PTR_ERR(mux->pinctrl); ret = PTR_ERR(mux->pinctrl);
dev_err(&pdev->dev, "Cannot get pinctrl: %d\n", ret); dev_err(dev, "Cannot get pinctrl: %d\n", ret);
goto err; goto err_put_parent;
} }
for (i = 0; i < mux->pdata->bus_count; i++) {
mux->states[i] = pinctrl_lookup_state(mux->pinctrl, for (i = 0; i < num_names; i++) {
mux->pdata->pinctrl_states[i]); ret = of_property_read_string_index(np, "pinctrl-names", i,
&name);
if (ret < 0) {
dev_err(dev, "Cannot parse pinctrl-names: %d\n", ret);
goto err_put_parent;
}
mux->states[i] = pinctrl_lookup_state(mux->pinctrl, name);
if (IS_ERR(mux->states[i])) { if (IS_ERR(mux->states[i])) {
ret = PTR_ERR(mux->states[i]); ret = PTR_ERR(mux->states[i]);
dev_err(&pdev->dev, dev_err(dev, "Cannot look up pinctrl state %s: %d\n",
"Cannot look up pinctrl state %s: %d\n", name, ret);
mux->pdata->pinctrl_states[i], ret); goto err_put_parent;
goto err;
}
}
if (mux->pdata->pinctrl_state_idle) {
mux->state_idle = pinctrl_lookup_state(mux->pinctrl,
mux->pdata->pinctrl_state_idle);
if (IS_ERR(mux->state_idle)) {
ret = PTR_ERR(mux->state_idle);
dev_err(&pdev->dev,
"Cannot look up pinctrl state %s: %d\n",
mux->pdata->pinctrl_state_idle, ret);
goto err;
} }
muxc->deselect = i2c_mux_pinctrl_deselect; if (strcmp(name, "idle"))
} continue;
muxc->parent = i2c_get_adapter(mux->pdata->parent_bus_num); if (i != num_names - 1) {
if (!muxc->parent) { dev_err(dev, "idle state must be last\n");
dev_err(&pdev->dev, "Parent adapter (%d) not found\n", ret = -EINVAL;
mux->pdata->parent_bus_num); goto err_put_parent;
ret = -EPROBE_DEFER; }
goto err; muxc->deselect = i2c_mux_pinctrl_deselect;
} }
root = i2c_root_adapter(&muxc->parent->dev); root = i2c_root_adapter(&muxc->parent->dev);
muxc->mux_locked = true; muxc->mux_locked = true;
for (i = 0; i < mux->pdata->bus_count; i++) { for (i = 0; i < num_names; i++) {
if (root != i2c_mux_pinctrl_root_adapter(mux->states[i])) { if (root != i2c_mux_pinctrl_root_adapter(mux->states[i])) {
muxc->mux_locked = false; muxc->mux_locked = false;
break; break;
} }
} }
if (muxc->mux_locked && mux->pdata->pinctrl_state_idle &&
root != i2c_mux_pinctrl_root_adapter(mux->state_idle))
muxc->mux_locked = false;
if (muxc->mux_locked) if (muxc->mux_locked)
dev_info(&pdev->dev, "mux-locked i2c mux\n"); dev_info(dev, "mux-locked i2c mux\n");
for (i = 0; i < mux->pdata->bus_count; i++) { /* Do not add any adapter for the idle state (if it's there at all). */
u32 bus = mux->pdata->base_bus_num ? for (i = 0; i < num_names - !!muxc->deselect; i++) {
(mux->pdata->base_bus_num + i) : 0; ret = i2c_mux_add_adapter(muxc, 0, i, 0);
ret = i2c_mux_add_adapter(muxc, bus, i, 0);
if (ret) if (ret)
goto err_del_adapter; goto err_del_adapter;
} }
...@@ -253,8 +172,9 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev) ...@@ -253,8 +172,9 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
err_del_adapter: err_del_adapter:
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); err_put_parent:
err: i2c_put_adapter(parent);
return ret; return ret;
} }
...@@ -264,16 +184,15 @@ static int i2c_mux_pinctrl_remove(struct platform_device *pdev) ...@@ -264,16 +184,15 @@ static int i2c_mux_pinctrl_remove(struct platform_device *pdev)
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
i2c_put_adapter(muxc->parent); i2c_put_adapter(muxc->parent);
return 0; return 0;
} }
#ifdef CONFIG_OF
static const struct of_device_id i2c_mux_pinctrl_of_match[] = { static const struct of_device_id i2c_mux_pinctrl_of_match[] = {
{ .compatible = "i2c-mux-pinctrl", }, { .compatible = "i2c-mux-pinctrl", },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, i2c_mux_pinctrl_of_match); MODULE_DEVICE_TABLE(of, i2c_mux_pinctrl_of_match);
#endif
static struct platform_driver i2c_mux_pinctrl_driver = { static struct platform_driver i2c_mux_pinctrl_driver = {
.driver = { .driver = {
......
/*
* i2c-mux-pinctrl platform data
*
* Copyright (c) 2012, NVIDIA CORPORATION. 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 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LINUX_I2C_MUX_PINCTRL_H
#define _LINUX_I2C_MUX_PINCTRL_H
/**
* struct i2c_mux_pinctrl_platform_data - Platform data for i2c-mux-pinctrl
* @parent_bus_num: Parent I2C bus number
* @base_bus_num: Base I2C bus number for the child busses. 0 for dynamic.
* @bus_count: Number of child busses. Also the number of elements in
* @pinctrl_states
* @pinctrl_states: The names of the pinctrl state to select for each child bus
* @pinctrl_state_idle: The pinctrl state to select when no child bus is being
* accessed. If NULL, the most recently used pinctrl state will be left
* selected.
*/
struct i2c_mux_pinctrl_platform_data {
int parent_bus_num;
int base_bus_num;
int bus_count;
const char **pinctrl_states;
const char *pinctrl_state_idle;
};
#endif
/*
* i2c-bfin-twi.h - interface to ADI TWI controller
*
* Copyright 2005-2014 Analog Devices Inc.
*
* Licensed under the GPL-2 or later.
*/
#ifndef __I2C_BFIN_TWI_H__
#define __I2C_BFIN_TWI_H__
#include <linux/types.h>
#include <linux/i2c.h>
/*
* ADI twi registers layout
*/
struct bfin_twi_regs {
u16 clkdiv;
u16 dummy1;
u16 control;
u16 dummy2;
u16 slave_ctl;
u16 dummy3;
u16 slave_stat;
u16 dummy4;
u16 slave_addr;
u16 dummy5;
u16 master_ctl;
u16 dummy6;
u16 master_stat;
u16 dummy7;
u16 master_addr;
u16 dummy8;
u16 int_stat;
u16 dummy9;
u16 int_mask;
u16 dummy10;
u16 fifo_ctl;
u16 dummy11;
u16 fifo_stat;
u16 dummy12;
u32 __pad[20];
u16 xmt_data8;
u16 dummy13;
u16 xmt_data16;
u16 dummy14;
u16 rcv_data8;
u16 dummy15;
u16 rcv_data16;
u16 dummy16;
};
struct bfin_twi_iface {
int irq;
spinlock_t lock;
char read_write;
u8 command;
u8 *transPtr;
int readNum;
int writeNum;
int cur_mode;
int manual_stop;
int result;
struct i2c_adapter adap;
struct completion complete;
struct i2c_msg *pmsg;
int msg_num;
int cur_msg;
u16 saved_clkdiv;
u16 saved_control;
struct bfin_twi_regs __iomem *regs_base;
};
/* ******************** TWO-WIRE INTERFACE (TWI) MASKS ********************/
/* TWI_CLKDIV Macros (Use: *pTWI_CLKDIV = CLKLOW(x)|CLKHI(y); ) */
#define CLKLOW(x) ((x) & 0xFF) /* Periods Clock Is Held Low */
#define CLKHI(y) (((y)&0xFF)<<0x8) /* Periods Before New Clock Low */
/* TWI_PRESCALE Masks */
#define PRESCALE 0x007F /* SCLKs Per Internal Time Reference (10MHz) */
#define TWI_ENA 0x0080 /* TWI Enable */
#define SCCB 0x0200 /* SCCB Compatibility Enable */
/* TWI_SLAVE_CTL Masks */
#define SEN 0x0001 /* Slave Enable */
#define SADD_LEN 0x0002 /* Slave Address Length */
#define STDVAL 0x0004 /* Slave Transmit Data Valid */
#define NAK 0x0008 /* NAK Generated At Conclusion Of Transfer */
#define GEN 0x0010 /* General Call Address Matching Enabled */
/* TWI_SLAVE_STAT Masks */
#define SDIR 0x0001 /* Slave Transfer Direction (RX/TX*) */
#define GCALL 0x0002 /* General Call Indicator */
/* TWI_MASTER_CTL Masks */
#define MEN 0x0001 /* Master Mode Enable */
#define MADD_LEN 0x0002 /* Master Address Length */
#define MDIR 0x0004 /* Master Transmit Direction (RX/TX*) */
#define FAST 0x0008 /* Use Fast Mode Timing Specs */
#define STOP 0x0010 /* Issue Stop Condition */
#define RSTART 0x0020 /* Repeat Start or Stop* At End Of Transfer */
#define DCNT 0x3FC0 /* Data Bytes To Transfer */
#define SDAOVR 0x4000 /* Serial Data Override */
#define SCLOVR 0x8000 /* Serial Clock Override */
/* TWI_MASTER_STAT Masks */
#define MPROG 0x0001 /* Master Transfer In Progress */
#define LOSTARB 0x0002 /* Lost Arbitration Indicator (Xfer Aborted) */
#define ANAK 0x0004 /* Address Not Acknowledged */
#define DNAK 0x0008 /* Data Not Acknowledged */
#define BUFRDERR 0x0010 /* Buffer Read Error */
#define BUFWRERR 0x0020 /* Buffer Write Error */
#define SDASEN 0x0040 /* Serial Data Sense */
#define SCLSEN 0x0080 /* Serial Clock Sense */
#define BUSBUSY 0x0100 /* Bus Busy Indicator */
/* TWI_INT_SRC and TWI_INT_ENABLE Masks */
#define SINIT 0x0001 /* Slave Transfer Initiated */
#define SCOMP 0x0002 /* Slave Transfer Complete */
#define SERR 0x0004 /* Slave Transfer Error */
#define SOVF 0x0008 /* Slave Overflow */
#define MCOMP 0x0010 /* Master Transfer Complete */
#define MERR 0x0020 /* Master Transfer Error */
#define XMTSERV 0x0040 /* Transmit FIFO Service */
#define RCVSERV 0x0080 /* Receive FIFO Service */
/* TWI_FIFO_CTRL Masks */
#define XMTFLUSH 0x0001 /* Transmit Buffer Flush */
#define RCVFLUSH 0x0002 /* Receive Buffer Flush */
#define XMTINTLEN 0x0004 /* Transmit Buffer Interrupt Length */
#define RCVINTLEN 0x0008 /* Receive Buffer Interrupt Length */
/* TWI_FIFO_STAT Masks */
#define XMTSTAT 0x0003 /* Transmit FIFO Status */
#define XMT_EMPTY 0x0000 /* Transmit FIFO Empty */
#define XMT_HALF 0x0001 /* Transmit FIFO Has 1 Byte To Write */
#define XMT_FULL 0x0003 /* Transmit FIFO Full (2 Bytes To Write) */
#define RCVSTAT 0x000C /* Receive FIFO Status */
#define RCV_EMPTY 0x0000 /* Receive FIFO Empty */
#define RCV_HALF 0x0004 /* Receive FIFO Has 1 Byte To Read */
#define RCV_FULL 0x000C /* Receive FIFO Full (2 Bytes To Read) */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment