S905X|S905X 7.1 RTC_AM1805 移植 F&Q

由于S912 和 S905X 的 i2c 总线不一样,然后修改DTS 中的i2c 配置后连设备都找不到。后面还是修改驱动,在驱动中添加i2c 判断:

+++ b/drivers/amlogic/rtc/rtc_am1805.c @@ -1106,34 +1106,42 @@ static int rtc_am1805_probe(struct platform_device *pdev) unsigned int i2c_index; const char *str; unsigned long init_data = https://www.it610.com/article/0; - +RTC_DBG(RTC_DBG_VAL,"rtc_am1805 -- rtc_am1805_probe\n"); +pr_info("[%s] %d:rtc_am1805_probe!\n", __func__, __LINE__); priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->i2c_bus_index = 0xff; priv->dev = &pdev->dev; - /* for i2c bus */ +pr_info("[%s] %d:rtc_am1805_probe!\n", __func__, __LINE__); ret = of_property_read_string(node, "i2c_bus", &str); if (ret) { pr_info("[%s]: faild to get i2c_bus str!\n", __func__); goto out; } else { -if (!strncmp(str, "i2c_bus_ao", 9)) +pr_info("[%s] %d:rtc_am1805_probe!\n", __func__, __LINE__); +if (!strncmp(str, "i2c_bus_ao", 9)) { i2c_index = AML_I2C_MASTER_AO; -else if (!strncmp(str, "i2c_bus_a", 9)) +priv->i2c_bus_index = AML_I2C_MASTER_AO; +} else if (!strncmp(str, "i2c_bus_a", 9)) { i2c_index = AML_I2C_MASTER_A; -else if (!strncmp(str, "i2c_bus_b", 9)) +priv->i2c_bus_index = AML_I2C_MASTER_A; +} else if (!strncmp(str, "i2c_bus_b", 9)) { i2c_index = AML_I2C_MASTER_B; -else if (!strncmp(str, "i2c_bus_c", 9)) +priv->i2c_bus_index = AML_I2C_MASTER_B; +} else if (!strncmp(str, "i2c_bus_c", 9)) { i2c_index = AML_I2C_MASTER_C; -else -else if (!strncmp(str, "i2c_bus_d", 9)) +priv->i2c_bus_index = AML_I2C_MASTER_C; +} else if (!strncmp(str, "i2c_bus_d", 9)) { i2c_index = AML_I2C_MASTER_D; +priv->i2c_bus_index = AML_I2C_MASTER_D; +} else { goto out; +} +pr_info("[%s] %d:rtc_am1805_probe!\n", __func__, __LINE__); +add_timer(&rtc_info->timer); } -priv->i2c_bus_index = AML_I2C_MASTER_B; #if 0 /* for alarm irq */ @@ -1247,6 +1255,7 @@ static int rtc_am1805_probe(struct platform_device *pdev)return 0; out: +RTC_DBG(RTC_DBG_VAL, "rtc_am1805 -- goto out\n"); kfree(priv); return ret; } @@ -1299,6 +1308,7 @@ struct platform_driver rtc_am1805_driver = {static int__init rtc_am1805_init(void) { +RTC_DBG(RTC_DBG_VAL, "rtc_am1805 --rtc_am1805_init new\n"); RTC_DBG(RTC_DBG_VAL, "rtc_am1805 --rtc_am1805_init\n"); return platform_driver_register(&rtc_am1805_driver); }

DTS 修改:
rtc { compatible = "amlogic, rtc_am1805"; dev_name = "rtc_am1805"; status = "okay"; reg = <0x69>; /** device i2c address, must have*/ i2c_bus = "i2c_bus_ao"; init_date = "2015/01/01"; }; ```#移植完经测试发现rtc 的时间不能保存,查看log发现 获取时间判断:

【S905X|S905X 7.1 RTC_AM1805 移植 F&Q】static int get_rtc_am1805_status(void)
return -1;
if (ptime.month > 12)
return -1;
  • if (ptime.day > rtc_month_days(ptime.month, ptime.year)){

  • pr_err("%s days err.",__func__);

  • return -1;

  • }
  • if (ptime.day > 31) {

  • pr_err("%s days err.", __func__);

  • return -1;

  • }


    推荐阅读