[i2c] [PATCH] i2c: Deprecate legacy RTC drivers
David Brownell
david-b at pacbell.net
Mon May 14 18:47:45 CEST 2007
On Monday 14 May 2007, James Chapman wrote:
> Hi Dave,
>
> I've already acked Jean's patch.
That's a start. We also want to move away from legacy I2C drivers too...
> I'm waiting for the board vendor to test a ppc7d patch that removes the
> use of the rtc hooks and switches over to rtc-ds1307 as you describe.
> I'll submit it to the ppc maintainers once the board vendor has verified it.
Appended is the patch I had in mind ... in conjunction with patches to
convert rtc-ds1307 to a new-style I2C driver (which I've just sent,
and CC'd you on), and defconfig updates.
- Dave
===== CUT HERE
Non-Kconfig parts of moving the Radstone PPC7D platform from the old
ds1337 driver over to the new RTC framework and rtc-ds1307.c driver.
Kconfig needs to select RTC_DS1307 and RTC_HCTOSYS.
This is a prerequisite to removing the legacy i2c-ds1337.c driver,
then switching rtc-ds1307.c to be a new-style driver.
EXPERIMENTAL, UNTESTED.
Signed-off-by: David Brownell <dbrownell at users.sourceforge.net>
---
arch/ppc/platforms/radstone_ppc7d.c | 49 ++++++++----------------------------
drivers/i2c/busses/i2c-mv64xxx.c | 3 +-
2 files changed, 13 insertions(+), 39 deletions(-)
--- at91.orig/arch/ppc/platforms/radstone_ppc7d.c 2007-05-12 23:31:25.000000000 -0700
+++ at91/arch/ppc/platforms/radstone_ppc7d.c 2007-05-13 11:52:24.000000000 -0700
@@ -38,6 +38,7 @@
#include <linux/mv643xx.h>
#include <linux/netdevice.h>
#include <linux/platform_device.h>
+#include <linux/i2c.h>
#include <asm/system.h>
#include <asm/pgtable.h>
@@ -72,10 +73,6 @@ static int ppc7d_has_alma;
extern void gen550_progress(char *, unsigned short);
extern void gen550_init(int, struct uart_port *);
-/* FIXME - move to h file */
-extern int ds1337_do_command(int id, int cmd, void *arg);
-#define DS1337_GET_DATE 0
-#define DS1337_SET_DATE 1
/* residual data */
unsigned char __res[sizeof(bd_t)];
@@ -1242,37 +1239,6 @@ static void __init ppc7d_setup_arch(void
}
-/* Real Time Clock support.
- * PPC7D has a DS1337 accessed by I2C.
- */
-static ulong ppc7d_get_rtc_time(void)
-{
- struct rtc_time tm;
- int result;
-
- spin_lock(&rtc_lock);
- result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
- spin_unlock(&rtc_lock);
-
- if (result == 0)
- result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
-
- return result;
-}
-
-static int ppc7d_set_rtc_time(unsigned long nowtime)
-{
- struct rtc_time tm;
- int result;
-
- spin_lock(&rtc_lock);
- to_tm(nowtime, &tm);
- result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
- spin_unlock(&rtc_lock);
-
- return result;
-}
-
/* This kernel command line parameter can be used to have the target
* wait for a JTAG debugger to attach. Of course, a JTAG debugger
* with hardware breakpoint support can have the target stop at any
@@ -1290,6 +1256,13 @@ static int __init ppc7d_waitdbg(char *st
__setup("waitdbg", ppc7d_waitdbg);
+static struct i2c_board_info __initdata ppc7d_i2c_devices[] = {
+ { I2C_BOARD_INFO("rtc-ds1307", 0x68),
+ .type = "ds1337",
+ },
+};
+
+
/* Second phase board init, called after other (architecture common)
* low-level services have been initialized.
*/
@@ -1328,9 +1301,9 @@ static void ppc7d_init2(void)
data8 |= 0x07;
outb(data8, PPC7D_CPLD_LEDS);
- /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
- ppc_md.set_rtc_time = ppc7d_set_rtc_time;
- ppc_md.get_rtc_time = ppc7d_get_rtc_time;
+ /* Declare RTC; use the new RTC framework and CONFIG_RTC_HCTOSYS */
+ i2c_register_board_info(0, ppc7d_i2c_devices,
+ ARRAY_SIZE(ppc7d_i2c_devices));
pr_debug("%s: exit\n", __FUNCTION__);
}
--- at91.orig/drivers/i2c/busses/i2c-mv64xxx.c 2007-05-10 00:48:22.000000000 -0700
+++ at91/drivers/i2c/busses/i2c-mv64xxx.c 2007-05-13 10:06:25.000000000 -0700
@@ -529,6 +529,7 @@ mv64xxx_i2c_probe(struct platform_device
drv_data->adapter.retries = pdata->retries;
platform_set_drvdata(pd, drv_data);
i2c_set_adapdata(&drv_data->adapter, drv_data);
+ /* platform->adapter.nr == 0 */
mv64xxx_i2c_hw_init(drv_data);
@@ -539,7 +540,7 @@ mv64xxx_i2c_probe(struct platform_device
drv_data->irq);
rc = -EINVAL;
goto exit_unmap_regs;
- } else if ((rc = i2c_add_adapter(&drv_data->adapter)) != 0) {
+ } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) {
dev_err(&drv_data->adapter.dev,
"mv64xxx: Can't add i2c adapter, rc: %d\n", -rc);
goto exit_free_irq;
More information about the i2c
mailing list