Skip to contentSkip to conversation

i2c: SuperH Mobile I2C Bus Controller

PATCH In review Magnus Damm 2 participants 3 messages Mar 20, 2008 – Mar 21, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: SuperH Mobile I2C Bus Controller

This patch adds support for the I2C block found in SuperH Mobile processors such as sh7343, sh7722 and sh7723. Tested on a sh7722 MigoR board using the rs5c732b rtc chip.

---

 drivers/i2c/busses/Kconfig         |    8 
 drivers/i2c/busses/Makefile        |    1 
 drivers/i2c/busses/i2c-sh_mobile.c |  493 ++++++++++++++++++++++++++++++++++++
 3 files changed, 502 insertions(+)
drivers/i2c/busses/Kconfig +8 -0
@@ -672,4 +672,12 @@ config I2C_PMCMSP
 	  This driver can also be built as module. If so, the module
 	  will be called i2c-pmcmsp.
 
+config I2C_SH_MOBILE
+	tristate "SuperH Mobile I2C Controller"
+	help
+	  If you say yes to this option, support will be included for the
+	  built-in I2C interface on the Renesas SH-Mobile processor.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-sh_mobile.
 endmenu
drivers/i2c/busses/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_I2C_VIAPRO)	+= i2c-viapro.o
 obj-$(CONFIG_I2C_VOODOO3)	+= i2c-voodoo3.o
 obj-$(CONFIG_SCx200_ACB)	+= scx200_acb.o
 obj-$(CONFIG_SCx200_I2C)	+= scx200_i2c.o
+obj-$(CONFIG_I2C_SH_MOBILE)	+= i2c-sh_mobile.o
 
 ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/i2c/busses/i2c-sh_mobile.c new file +493 -0

493 lines not on this page · raw message

#1 lore raw

drivers/i2c/busses/i2c-sh_mobile.c line 317

Quoted 8 lines · Magnus Damm
drivers/i2c/busses/i2c-sh_mobile.c new file +8 -0
+static void sh_mobile_i2c_setup_channel(struct platform_device *dev)
+{
+	struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev);
+	unsigned long peripheral_clk = CONFIG_SH_PCLK_FREQ;
+	u_int32_t num;
+	u_int32_t denom;
+	u_int32_t tmp;
+

Use clk_get() and friends here for the module clock. This should absolutely not be hardcoded, especially as it can be scaled by the clock framework, and the i2c clock will need to rebalance itself to account for that. Any driver that references CONFIG_SH_PCLK_FREQ is utterly broken.

#2 lore raw
Quoted 13 lines · Paul Mundt

drivers/i2c/busses/i2c-sh_mobile.c line 317

Quoted 8 lines · Magnus Damm
drivers/i2c/busses/i2c-sh_mobile.c new file +8 -0
+static void sh_mobile_i2c_setup_channel(struct platform_device *dev)
+{
+     struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev);
+     unsigned long peripheral_clk = CONFIG_SH_PCLK_FREQ;
+     u_int32_t num;
+     u_int32_t denom;
+     u_int32_t tmp;
+

Use clk_get() and friends here for the module clock. This should absolutely not be hardcoded, especially as it can be scaled by the clock framework, and the i2c clock will need to rebalance itself to account for that. Any driver that references CONFIG_SH_PCLK_FREQ is utterly broken.

Thanks for spotting this. I'll fix this and repost V2 in a bit.

/ magnus