Add-Broadcom-Kona-I2C-Support
Subsystems (5)
v2 cover Add-Broadcom-Kona-I2C-Support
This series adds support for the Kona I2C bus found on Broadcom mobile SoCs like the bcm11351 (aka bcm281xx) and enables it on the bcm28155-ap board.
It depends upon the following commit:
http://lkml.indiana.edu/hypermail/linux/kernel/1311.1/03583.html
Tim Kryger (5):
Documentation: dt: Add i2c-bcm-kona binding
i2c: i2c-bcm-kona: Introduce Broadcom I2C Driver
i2c: i2c-bcm-kona: Add support for high-speed mode
ARM: dts: bcm281xx: Add i2c busses
ARM: dts: bcm28155-ap: Enable all the i2c busses
.../devicetree/bindings/i2c/i2c-bcm-kona.txt | 35 + arch/arm/boot/dts/bcm11351.dtsi | 40 + arch/arm/boot/dts/bcm28155-ap.dts | 20 + drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-bcm-kona.c | 908 +++++++++++++++++++++ 6 files changed, 1014 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-bcm-kona.txt create mode 100644 drivers/i2c/busses/i2c-bcm-kona.c
Signature · 1 line
1.8.0.1
PATCH v2 1/5 Documentation: dt: Add i2c-bcm-kona binding
Add the binding description for the i2c-bcm-kona block found on Broadcom's mobile SoCs.
--- .../devicetree/bindings/i2c/i2c-bcm-kona.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-bcm-kona.txt
Documentation/devicetree/bindings/i2c/i2c-bcm-kona.txt new file +35 -0
@@ -0,0 +1,35 @@ +Broadcom Kona Family I2C +========================= + +This I2C controller is used in the following Broadcom SoCs: + + BCM11130 + BCM11140 + BCM11351 + BCM28145 + BCM28155 + +Required Properties +------------------- +- compatible: "brcm,bcm11351-i2c", "brcm,kona-i2c" +- reg: Physical base address and length of controller registers +- interrupts: The interrupt number used by the controller +- clocks: clock specifier for the kona i2c external clock +- clock-frequency: The I2C bus frequency in Hz +- #address-cells: Should be <1> +- #size-cells: Should be <0> + +Refer to clocks/clock-bindings.txt for generic clock consumer +properties. + +Example: + +i2c at 3e016000 { + compatible = "brcm,bcm11351-i2c","brcm,kona-i2c"; + reg = <0x3e016000 0x80>; + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bsc1_clk>; + clock-frequency = <400000>; + #address-cells = <1>; + #size-cells = <0>; +};
Signature · 1 line
1.8.0.1
PATCH v2 2/5 i2c: i2c-bcm-kona: Introduce Broadcom I2C Driver
In reply to Tim KrygerIntroduce support for Broadcom Serial Controller (BSC) I2C bus found in the Kona family of Mobile SoCs. FIFO hardware is utilized but only standard mode (100kHz), fast mode (400kHz), and fast mode plus (1MHz) bus speeds are supported.
--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-bcm-kona.c | 795 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 806 insertions(+) create mode 100644 drivers/i2c/busses/i2c-bcm-kona.c
drivers/i2c/busses/Kconfig +10 -0
@@ -963,4 +963,14 @@ config SCx200_ACB This support is also available as a module. If so, the module will be called scx200_acb. +config I2C_BCM_KONA + tristate "BCM Kona I2C adapter" + depends on ARCH_BCM_MOBILE + default y + help + If you say yes to this option, support will be included for the + I2C interface on the Broadcom Kona family of processors. + + If you do not need KONA I2C inteface, say N. + endmenu
drivers/i2c/busses/Makefile +1 -0
@@ -87,6 +87,7 @@ obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o # Other I2C/SMBus bus drivers obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o +obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
drivers/i2c/busses/i2c-bcm-kona.c new file +795 -0
795 lines not on this page · raw message
Signature · 1 line
1.8.0.1
PATCH v2 3/5 i2c: i2c-bcm-kona: Add support for high-speed mode
In reply to Tim KrygerAdd support for I2C high-speed mode (3.4 MHz).
--- drivers/i2c/busses/i2c-bcm-kona.c | 115 +++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-bcm-kona.c +114 -1
@@ -77,6 +77,9 @@#define HSTIM_OFFSET 0x00000058#define HSTIM_HS_MODE_MASK 0x00008000 +#define HSTIM_HS_HOLD_SHIFT 10 +#define HSTIM_HS_HIGH_PHASE_SHIFT 5 +#define HSTIM_HS_SETUP_SHIFT 0#define PADCTL_OFFSET 0x0000005c#define PADCTL_PAD_OUT_EN_MASK 0x00000004
@@ -91,6 +94,9 @@#define MAX_TX_FIFO_SIZE 64U/* bytes */ #define STD_EXT_CLK_FREQ 13000000UL +#define HS_EXT_CLK_FREQ 104000000UL + +#define MASTERCODE 0x08/* Mastercodes are 0000_1xxxb */ #define I2C_TIMEOUT 100/* msecs */
@@ -108,6 +114,10 @@ enum bus_speed_index { BCM_SPD_1MHZ, }; +enum hs_bus_speed_index { +BCM_SPD_3P4MHZ =0 , +}; +/* Internal divider settings for standard mode, fast mode and fast mode plus */ struct bus_speed_cfg {uint8_t time_m;/* Number of cycles for setup time */
@@ -118,12 +128,30 @@ struct bus_speed_cfg {uint8_t time_div;/* Post-prescale divider */ }; +/* Internal divider settings for high-speed mode */ +struct hs_bus_speed_cfg { +uint8_t hs_hold;/* Number of clock cycles SCL stays low until +the end of bit period */ +uint8_t hs_high_phase;/* Number of clock cycles SCL stays high +before it falls */ +uint8_t hs_setup;/* Number of clock cycles SCL stays low +before it rises */ +uint8_t prescale;/* Prescale divider */ +uint8_t time_p;/* Timing coefficient */ +uint8_t no_div;/* Disable clock divider */ +uint8_t time_div;/* Post-prescale divider */ +}; +static const struct bus_speed_cfg std_cfg_table[] = { [BCM_SPD_100K ] = {0x01 ,0x01 ,0x03 ,0x06 ,0x00 ,0x02 }, [BCM_SPD_400K ] = {0x05 ,0x01 ,0x03 ,0x05 ,0x01 ,0x02 }, [BCM_SPD_1MHZ ] = {0x01 ,0x01 ,0x03 ,0x01 ,0x01 ,0x03 }, }; +static const struct hs_bus_speed_cfg hs_cfg_table[] = { + [BCM_SPD_3P4MHZ ] = {0x01 ,0x08 ,0x14 ,0x00 ,0x06 ,0x01 ,0x00 }, +}; +struct bcm_kona_i2c_dev {struct device *device;
@@ -136,6 +164,7 @@ struct bcm_kona_i2c_dev {struct completion done;const struct bus_speed_cfg *std_cfg; +const struct hs_bus_speed_cfg *hs_cfg; }; static void bcm_kona_i2c_send_cmd_to_ctrl(struct bcm_kona_i2c_dev *dev,
@@ -508,6 +537,70 @@ static void bcm_kona_i2c_config_timing(struct bcm_kona_i2c_dev *dev) dev->base + CLKEN_OFFSET); } +static void bcm_kona_i2c_config_timing_hs (struct bcm_kona_i2c_dev *dev) +{ +writel ((dev->hs_cfg->prescale <<TIM_PRESCALE_SHIFT ) | + (dev->hs_cfg->time_p <<TIM_P_SHIFT ) | + (dev->hs_cfg->no_div <<TIM_NO_DIV_SHIFT ) | + (dev->hs_cfg->time_div <<TIM_DIV_SHIFT ), + dev->base +TIM_OFFSET ); + +writel ((dev->hs_cfg->hs_hold <<HSTIM_HS_HOLD_SHIFT ) | + (dev->hs_cfg->hs_high_phase <<HSTIM_HS_HIGH_PHASE_SHIFT ) | + (dev->hs_cfg->hs_setup <<HSTIM_HS_SETUP_SHIFT ), + dev->base +HSTIM_OFFSET ); + +writel (readl (dev->base +HSTIM_OFFSET ) |HSTIM_HS_MODE_MASK , + dev->base +HSTIM_OFFSET ); +} + +static int bcm_kona_i2c_switch_to_hs (struct bcm_kona_i2c_dev *dev) +{ +int rc; + +/* Send mastercode at standard speed */ + rc =bcm_kona_i2c_write_byte (dev,MASTERCODE ,1 ); +if (rc <0 ) { +pr_err ("High speed handshake failed\n" ); +return rc; + } + +/* Configure external clock to higher frequency */ + rc =clk_set_rate (dev->external_clk,HS_EXT_CLK_FREQ ); +if (rc) { +dev_err (dev->device,"%s: clk_set_rate returned %d\n" , + __func__, rc); +return rc; + } + +/* Reconfigure internal dividers */ +bcm_kona_i2c_config_timing_hs (dev); + +/* Send a restart command */ + rc =bcm_kona_send_i2c_cmd (dev,BCM_CMD_RESTART ); +if (rc <0 ) +dev_err (dev->device,"High speed restart command failed\n" ); + +return rc; +} + +static int bcm_kona_i2c_switch_to_std (struct bcm_kona_i2c_dev *dev) +{ +int rc; + +/* Reconfigure internal dividers */ +bcm_kona_i2c_config_timing (dev); + +/* Configure external clock to lower frequency */ + rc =clk_set_rate (dev->external_clk,STD_EXT_CLK_FREQ ); +if (rc) { +dev_err (dev->device,"%s: clk_set_rate returned %d\n" , + __func__, rc); + } + +return rc; +} +/* Master transfer function */ static int bcm_kona_i2c_xfer (struct i2c_adapter *adapter,struct i2c_msg msgs[],int num)
@@ -537,6 +630,13 @@ static int bcm_kona_i2c_xfer(struct i2c_adapter *adapter, goto xfer_disable_pad; } +/* Switch to high speed if applicable */ +if (dev->hs_cfg) { + rc =bcm_kona_i2c_switch_to_hs (dev); +if (rc <0 ) + goto xfer_send_stop; + } +/* Loop through all messages */ for (i =0 ; i < num; i++) { pmsg = &msgs[i];
@@ -584,6 +684,14 @@ xfer_send_stop:/* Send a STOP command */ bcm_kona_send_i2c_cmd (dev,BCM_CMD_STOP ); +/* Return from high speed if applicable */ +if (dev->hs_cfg) { +int hs_rc =bcm_kona_i2c_switch_to_std (dev); + +if (hs_rc) + rc = hs_rc; + } + xfer_disable_pad:/* Disable pad output */ writel (PADCTL_PAD_OUT_EN_MASK , dev->base +PADCTL_OFFSET );
@@ -627,9 +735,14 @@ static int bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev)case 1000000 : dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ ];break ; +case 3400000 : +/* Send mastercode at 100k */ + dev->std_cfg = &std_cfg_table[BCM_SPD_100K ]; + dev->hs_cfg = &hs_cfg_table[BCM_SPD_3P4MHZ ]; +break ;default :pr_err ("%d hz bus speed not supported\n" , bus_speed); -pr_err ("Valid speeds are 100khz, 400khz, and 1mhz\n" ); +pr_err ("Valid speeds are 100khz, 400khz, 1mhz, and 3.4mhz\n" );return -EINVAL ; }
Signature · 1 line
1.8.0.1
PATCH v2 4/5 ARM: dts: bcm281xx: Add i2c busses
In reply to Tim KrygerAdd the DTS nodes for all the i2c busses in the SoC.
--- arch/arm/boot/dts/bcm11351.dtsi | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
arch/arm/boot/dts/bcm11351.dtsi +40 -0
@@ -146,6 +146,46 @@ status = "disabled"; }; + i2c at 3e016000 { + compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c"; + reg = <0x3e016000 0x80>; + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&bsc1_clk>; + status = "disabled"; + }; + + i2c at 3e017000 { + compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c"; + reg = <0x3e017000 0x80>; + interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&bsc2_clk>; + status = "disabled"; + }; + + i2c at 3e018000 { + compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c"; + reg = <0x3e018000 0x80>; + interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&bsc3_clk>; + status = "disabled"; + }; + + i2c at 3500d000 { + compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c"; + reg = <0x3500d000 0x80>; + interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&pmu_bsc_clk>; + status = "disabled"; + }; + clocks { bsc1_clk: bsc1 { compatible = "fixed-clock";
Signature · 1 line
1.8.0.1
PATCH v2 5/5 ARM: dts: bcm28155-ap: Enable all the i2c busses
In reply to Tim KrygerEnable all available i2c busses.
--- arch/arm/boot/dts/bcm28155-ap.dts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm/boot/dts/bcm28155-ap.dts +20 -0
@@ -27,6 +27,26 @@ status = "okay"; }; + i2c at 3e016000 { + status="okay"; + clock-frequency = <400000>; + }; + + i2c at 3e017000 { + status="okay"; + clock-frequency = <400000>; + }; + + i2c at 3e018000 { + status="okay"; + clock-frequency = <400000>; + }; + + i2c at 3500d000 { + status="okay"; + clock-frequency = <400000>; + }; + sdio1: sdio at 3f180000 { max-frequency = <48000000>; status = "okay";
Signature · 1 line
1.8.0.1
Quoted 6 lines · Tim Kryger
This series adds support for the Kona I2C bus found on Broadcom mobile SoCs like the bcm11351 (aka bcm281xx) and enables it on the bcm28155-ap board.
It depends upon the following commit:
http://lkml.indiana.edu/hypermail/linux/kernel/1311.1/03583.html
Fixed Kconfig sorting, squashed broken out patches 1-3 into one and applied to for-next, thanks! Let me know if I should take patches 4-5 also, but usually they go via arm-soc. Also, please provide a "Changes since V1" log which will speed up reviewing.
Thanks,
Wolfram
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131115/9aa11b15/attachment.sig>
Quoted 4 lines · Wolfram Sang
Fixed
Kconfigsorting, squashed broken out patches 1-3 into one and applied to for-next, thanks! Let me know if I should take patches 4-5 also, but usually they go via arm-soc. Also, please provide a "Changes since V1" log which will speed up reviewing.
Thanks. It appears that when I updated the dependencies, I accidentally removed the change list I had planned to send. This is what should have appeared in my cover letter:
Changes in v2:
- Binding documentation is in its own patch
- Minor cosmetic changes
- Fixed bug related to improper signedness
- Removed superflous mutex
- Simplified probe function
I think it would be best for the DTS changes (patches 4 and 5) to go through Christian's tree.
-Tim
Quoted 18 lines · Tim Kryger
Quoted 4 lines · Wolfram Sang
Fixed
Kconfigsorting, squashed broken out patches 1-3 into one and applied to for-next, thanks! Let me know if I should take patches 4-5 also, but usually they go via arm-soc. Also, please provide a "Changes since V1" log which will speed up reviewing.Thanks. It appears that when I updated the dependencies, I accidentally removed the change list I had planned to send. This is what should have appeared in my cover letter:
Changes in v2:
- Binding documentation is in its own patch
- Minor cosmetic changes
- Fixed bug related to improper signedness
- Removed superflous mutex
- Simplified probe function
Quoted 2 lines
I think it would be best for the DTS changes (patches 4 and 5) to go through Christian's tree.
I'll pick up 4 and 5.
thanks
csd