date: Drop the legacy I2C code
Drop two generations of old code in this command. All boards should use driver model for I2C from 2021. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:

committed by
Heiko Schocher

parent
9baa31ab09
commit
12d38c5a70
26
cmd/date.c
26
cmd/date.c
@@ -31,7 +31,6 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
int old_bus __maybe_unused;
|
int old_bus __maybe_unused;
|
||||||
|
|
||||||
/* switch to correct I2C bus */
|
/* switch to correct I2C bus */
|
||||||
#ifdef CONFIG_DM_RTC
|
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
|
||||||
rcode = uclass_get_device_by_seq(UCLASS_RTC, 0, &dev);
|
rcode = uclass_get_device_by_seq(UCLASS_RTC, 0, &dev);
|
||||||
@@ -42,29 +41,19 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 2: /* set date & time */
|
case 2: /* set date & time */
|
||||||
if (strcmp(argv[1],"reset") == 0) {
|
if (strcmp(argv[1],"reset") == 0) {
|
||||||
puts ("Reset RTC...\n");
|
puts ("Reset RTC...\n");
|
||||||
#ifdef CONFIG_DM_RTC
|
|
||||||
rcode = dm_rtc_reset(dev);
|
rcode = dm_rtc_reset(dev);
|
||||||
if (!rcode)
|
if (!rcode)
|
||||||
rcode = dm_rtc_set(dev, &default_tm);
|
rcode = dm_rtc_set(dev, &default_tm);
|
||||||
#else
|
|
||||||
rtc_reset();
|
|
||||||
rcode = rtc_set(&default_tm);
|
|
||||||
#endif
|
|
||||||
if (rcode)
|
if (rcode)
|
||||||
puts("## Failed to set date after RTC reset\n");
|
puts("## Failed to set date after RTC reset\n");
|
||||||
} else {
|
} else {
|
||||||
/* initialize tm with current time */
|
/* initialize tm with current time */
|
||||||
#ifdef CONFIG_DM_RTC
|
|
||||||
rcode = dm_rtc_get(dev, &tm);
|
rcode = dm_rtc_get(dev, &tm);
|
||||||
#else
|
|
||||||
rcode = rtc_get(&tm);
|
|
||||||
#endif
|
|
||||||
if (!rcode) {
|
if (!rcode) {
|
||||||
/* insert new date & time */
|
/* insert new date & time */
|
||||||
if (mk_date(argv[1], &tm) != 0) {
|
if (mk_date(argv[1], &tm) != 0) {
|
||||||
@@ -72,11 +61,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* and write to RTC */
|
/* and write to RTC */
|
||||||
#ifdef CONFIG_DM_RTC
|
|
||||||
rcode = dm_rtc_set(dev, &tm);
|
rcode = dm_rtc_set(dev, &tm);
|
||||||
#else
|
|
||||||
rcode = rtc_set(&tm);
|
|
||||||
#endif
|
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
printf("## Set date failed: err=%d\n",
|
printf("## Set date failed: err=%d\n",
|
||||||
rcode);
|
rcode);
|
||||||
@@ -87,11 +72,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
}
|
}
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case 1: /* get date & time */
|
case 1: /* get date & time */
|
||||||
#ifdef CONFIG_DM_RTC
|
|
||||||
rcode = dm_rtc_get(dev, &tm);
|
rcode = dm_rtc_get(dev, &tm);
|
||||||
#else
|
|
||||||
rcode = rtc_get(&tm);
|
|
||||||
#endif
|
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
puts("## Get date failed\n");
|
puts("## Get date failed\n");
|
||||||
break;
|
break;
|
||||||
@@ -108,13 +89,6 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
rcode = CMD_RET_USAGE;
|
rcode = CMD_RET_USAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* switch back to original I2C bus */
|
|
||||||
#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
|
|
||||||
i2c_set_bus_num(old_bus);
|
|
||||||
#elif !defined(CONFIG_DM_RTC)
|
|
||||||
I2C_SET_BUS(old_bus);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return rcode ? CMD_RET_FAILURE : 0;
|
return rcode ? CMD_RET_FAILURE : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user