diff options
| -rw-r--r-- | drivers/mfd/da9063-core.c | 6 | ||||
| -rw-r--r-- | drivers/mfd/da9063-i2c.c | 134 | ||||
| -rw-r--r-- | drivers/rtc/rtc-da9063.c | 54 | ||||
| -rw-r--r-- | include/linux/mfd/da9063/core.h | 3 | ||||
| -rw-r--r-- | include/linux/mfd/da9063/registers.h | 129 |
5 files changed, 236 insertions, 90 deletions
diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c index e70ae315abc7..93db8bb8c8f0 100644 --- a/drivers/mfd/da9063-core.c +++ b/drivers/mfd/da9063-core.c | |||
| @@ -153,9 +153,9 @@ int da9063_device_init(struct da9063 *da9063, unsigned int irq) | |||
| 153 | "Device detected (chip-ID: 0x%02X, var-ID: 0x%02X)\n", | 153 | "Device detected (chip-ID: 0x%02X, var-ID: 0x%02X)\n", |
| 154 | model, variant_id); | 154 | model, variant_id); |
| 155 | 155 | ||
| 156 | if (variant_code != PMIC_DA9063_BB) { | 156 | if (variant_code < PMIC_DA9063_BB && variant_code != PMIC_DA9063_AD) { |
| 157 | dev_err(da9063->dev, "Unknown chip variant code: 0x%02X\n", | 157 | dev_err(da9063->dev, |
| 158 | variant_code); | 158 | "Cannot support variant code: 0x%02X\n", variant_code); |
| 159 | return -ENODEV; | 159 | return -ENODEV; |
| 160 | } | 160 | } |
| 161 | 161 | ||
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c index 8db5c805c64f..21fd8d9a217b 100644 --- a/drivers/mfd/da9063-i2c.c +++ b/drivers/mfd/da9063-i2c.c | |||
| @@ -25,10 +25,10 @@ | |||
| 25 | #include <linux/mfd/da9063/pdata.h> | 25 | #include <linux/mfd/da9063/pdata.h> |
| 26 | #include <linux/mfd/da9063/registers.h> | 26 | #include <linux/mfd/da9063/registers.h> |
| 27 | 27 | ||
| 28 | static const struct regmap_range da9063_readable_ranges[] = { | 28 | static const struct regmap_range da9063_ad_readable_ranges[] = { |
| 29 | { | 29 | { |
| 30 | .range_min = DA9063_REG_PAGE_CON, | 30 | .range_min = DA9063_REG_PAGE_CON, |
| 31 | .range_max = DA9063_REG_SECOND_D, | 31 | .range_max = DA9063_AD_REG_SECOND_D, |
| 32 | }, { | 32 | }, { |
| 33 | .range_min = DA9063_REG_SEQ, | 33 | .range_min = DA9063_REG_SEQ, |
| 34 | .range_max = DA9063_REG_ID_32_31, | 34 | .range_max = DA9063_REG_ID_32_31, |
| @@ -37,14 +37,14 @@ static const struct regmap_range da9063_readable_ranges[] = { | |||
| 37 | .range_max = DA9063_REG_AUTO3_LOW, | 37 | .range_max = DA9063_REG_AUTO3_LOW, |
| 38 | }, { | 38 | }, { |
| 39 | .range_min = DA9063_REG_T_OFFSET, | 39 | .range_min = DA9063_REG_T_OFFSET, |
| 40 | .range_max = DA9063_REG_GP_ID_19, | 40 | .range_max = DA9063_AD_REG_GP_ID_19, |
| 41 | }, { | 41 | }, { |
| 42 | .range_min = DA9063_REG_CHIP_ID, | 42 | .range_min = DA9063_REG_CHIP_ID, |
| 43 | .range_max = DA9063_REG_CHIP_VARIANT, | 43 | .range_max = DA9063_REG_CHIP_VARIANT, |
| 44 | }, | 44 | }, |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | static const struct regmap_range da9063_writeable_ranges[] = { | 47 | static const struct regmap_range da9063_ad_writeable_ranges[] = { |
| 48 | { | 48 | { |
| 49 | .range_min = DA9063_REG_PAGE_CON, | 49 | .range_min = DA9063_REG_PAGE_CON, |
| 50 | .range_max = DA9063_REG_PAGE_CON, | 50 | .range_max = DA9063_REG_PAGE_CON, |
| @@ -53,7 +53,7 @@ static const struct regmap_range da9063_writeable_ranges[] = { | |||
| 53 | .range_max = DA9063_REG_VSYS_MON, | 53 | .range_max = DA9063_REG_VSYS_MON, |
| 54 | }, { | 54 | }, { |
| 55 | .range_min = DA9063_REG_COUNT_S, | 55 | .range_min = DA9063_REG_COUNT_S, |
| 56 | .range_max = DA9063_REG_ALARM_Y, | 56 | .range_max = DA9063_AD_REG_ALARM_Y, |
| 57 | }, { | 57 | }, { |
| 58 | .range_min = DA9063_REG_SEQ, | 58 | .range_min = DA9063_REG_SEQ, |
| 59 | .range_max = DA9063_REG_ID_32_31, | 59 | .range_max = DA9063_REG_ID_32_31, |
| @@ -62,14 +62,14 @@ static const struct regmap_range da9063_writeable_ranges[] = { | |||
| 62 | .range_max = DA9063_REG_AUTO3_LOW, | 62 | .range_max = DA9063_REG_AUTO3_LOW, |
| 63 | }, { | 63 | }, { |
| 64 | .range_min = DA9063_REG_CONFIG_I, | 64 | .range_min = DA9063_REG_CONFIG_I, |
| 65 | .range_max = DA9063_REG_MON_REG_4, | 65 | .range_max = DA9063_AD_REG_MON_REG_4, |
| 66 | }, { | 66 | }, { |
| 67 | .range_min = DA9063_REG_GP_ID_0, | 67 | .range_min = DA9063_AD_REG_GP_ID_0, |
| 68 | .range_max = DA9063_REG_GP_ID_19, | 68 | .range_max = DA9063_AD_REG_GP_ID_19, |
| 69 | }, | 69 | }, |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | static const struct regmap_range da9063_volatile_ranges[] = { | 72 | static const struct regmap_range da9063_ad_volatile_ranges[] = { |
| 73 | { | 73 | { |
| 74 | .range_min = DA9063_REG_STATUS_A, | 74 | .range_min = DA9063_REG_STATUS_A, |
| 75 | .range_max = DA9063_REG_EVENT_D, | 75 | .range_max = DA9063_REG_EVENT_D, |
| @@ -81,26 +81,104 @@ static const struct regmap_range da9063_volatile_ranges[] = { | |||
| 81 | .range_max = DA9063_REG_ADC_MAN, | 81 | .range_max = DA9063_REG_ADC_MAN, |
| 82 | }, { | 82 | }, { |
| 83 | .range_min = DA9063_REG_ADC_RES_L, | 83 | .range_min = DA9063_REG_ADC_RES_L, |
| 84 | .range_max = DA9063_REG_SECOND_D, | 84 | .range_max = DA9063_AD_REG_SECOND_D, |
| 85 | }, { | 85 | }, { |
| 86 | .range_min = DA9063_REG_MON_REG_5, | 86 | .range_min = DA9063_AD_REG_MON_REG_5, |
| 87 | .range_max = DA9063_REG_MON_REG_6, | 87 | .range_max = DA9063_AD_REG_MON_REG_6, |
| 88 | }, | 88 | }, |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| 91 | static const struct regmap_access_table da9063_readable_table = { | 91 | static const struct regmap_access_table da9063_ad_readable_table = { |
| 92 | .yes_ranges = da9063_readable_ranges, | 92 | .yes_ranges = da9063_ad_readable_ranges, |
| 93 | .n_yes_ranges = ARRAY_SIZE(da9063_readable_ranges), | 93 | .n_yes_ranges = ARRAY_SIZE(da9063_ad_readable_ranges), |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static const struct regmap_access_table da9063_writeable_table = { | 96 | static const struct regmap_access_table da9063_ad_writeable_table = { |
| 97 | .yes_ranges = da9063_writeable_ranges, | 97 | .yes_ranges = da9063_ad_writeable_ranges, |
| 98 | .n_yes_ranges = ARRAY_SIZE(da9063_writeable_ranges), | 98 | .n_yes_ranges = ARRAY_SIZE(da9063_ad_writeable_ranges), |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | static const struct regmap_access_table da9063_volatile_table = { | 101 | static const struct regmap_access_table da9063_ad_volatile_table = { |
| 102 | .yes_ranges = da9063_volatile_ranges, | 102 | .yes_ranges = da9063_ad_volatile_ranges, |
| 103 | .n_yes_ranges = ARRAY_SIZE(da9063_volatile_ranges), | 103 | .n_yes_ranges = ARRAY_SIZE(da9063_ad_volatile_ranges), |
| 104 | }; | ||
| 105 | |||
| 106 | static const struct regmap_range da9063_bb_readable_ranges[] = { | ||
| 107 | { | ||
| 108 | .range_min = DA9063_REG_PAGE_CON, | ||
| 109 | .range_max = DA9063_BB_REG_SECOND_D, | ||
| 110 | }, { | ||
| 111 | .range_min = DA9063_REG_SEQ, | ||
| 112 | .range_max = DA9063_REG_ID_32_31, | ||
| 113 | }, { | ||
| 114 | .range_min = DA9063_REG_SEQ_A, | ||
| 115 | .range_max = DA9063_REG_AUTO3_LOW, | ||
| 116 | }, { | ||
| 117 | .range_min = DA9063_REG_T_OFFSET, | ||
| 118 | .range_max = DA9063_BB_REG_GP_ID_19, | ||
| 119 | }, { | ||
| 120 | .range_min = DA9063_REG_CHIP_ID, | ||
| 121 | .range_max = DA9063_REG_CHIP_VARIANT, | ||
| 122 | }, | ||
| 123 | }; | ||
| 124 | |||
| 125 | static const struct regmap_range da9063_bb_writeable_ranges[] = { | ||
| 126 | { | ||
| 127 | .range_min = DA9063_REG_PAGE_CON, | ||
| 128 | .range_max = DA9063_REG_PAGE_CON, | ||
| 129 | }, { | ||
| 130 | .range_min = DA9063_REG_FAULT_LOG, | ||
| 131 | .range_max = DA9063_REG_VSYS_MON, | ||
| 132 | }, { | ||
| 133 | .range_min = DA9063_REG_COUNT_S, | ||
| 134 | .range_max = DA9063_BB_REG_ALARM_Y, | ||
| 135 | }, { | ||
| 136 | .range_min = DA9063_REG_SEQ, | ||
| 137 | .range_max = DA9063_REG_ID_32_31, | ||
| 138 | }, { | ||
| 139 | .range_min = DA9063_REG_SEQ_A, | ||
| 140 | .range_max = DA9063_REG_AUTO3_LOW, | ||
| 141 | }, { | ||
| 142 | .range_min = DA9063_REG_CONFIG_I, | ||
| 143 | .range_max = DA9063_BB_REG_MON_REG_4, | ||
| 144 | }, { | ||
| 145 | .range_min = DA9063_BB_REG_GP_ID_0, | ||
| 146 | .range_max = DA9063_BB_REG_GP_ID_19, | ||
| 147 | }, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static const struct regmap_range da9063_bb_volatile_ranges[] = { | ||
| 151 | { | ||
| 152 | .range_min = DA9063_REG_STATUS_A, | ||
| 153 | .range_max = DA9063_REG_EVENT_D, | ||
| 154 | }, { | ||
| 155 | .range_min = DA9063_REG_CONTROL_F, | ||
| 156 | .range_max = DA9063_REG_CONTROL_F, | ||
| 157 | }, { | ||
| 158 | .range_min = DA9063_REG_ADC_MAN, | ||
| 159 | .range_max = DA9063_REG_ADC_MAN, | ||
| 160 | }, { | ||
| 161 | .range_min = DA9063_REG_ADC_RES_L, | ||
| 162 | .range_max = DA9063_BB_REG_SECOND_D, | ||
| 163 | }, { | ||
| 164 | .range_min = DA9063_BB_REG_MON_REG_5, | ||
| 165 | .range_max = DA9063_BB_REG_MON_REG_6, | ||
| 166 | }, | ||
| 167 | }; | ||
| 168 | |||
| 169 | static const struct regmap_access_table da9063_bb_readable_table = { | ||
| 170 | .yes_ranges = da9063_bb_readable_ranges, | ||
| 171 | .n_yes_ranges = ARRAY_SIZE(da9063_bb_readable_ranges), | ||
| 172 | }; | ||
| 173 | |||
| 174 | static const struct regmap_access_table da9063_bb_writeable_table = { | ||
| 175 | .yes_ranges = da9063_bb_writeable_ranges, | ||
| 176 | .n_yes_ranges = ARRAY_SIZE(da9063_bb_writeable_ranges), | ||
| 177 | }; | ||
| 178 | |||
| 179 | static const struct regmap_access_table da9063_bb_volatile_table = { | ||
| 180 | .yes_ranges = da9063_bb_volatile_ranges, | ||
| 181 | .n_yes_ranges = ARRAY_SIZE(da9063_bb_volatile_ranges), | ||
| 104 | }; | 182 | }; |
| 105 | 183 | ||
| 106 | static const struct regmap_range_cfg da9063_range_cfg[] = { | 184 | static const struct regmap_range_cfg da9063_range_cfg[] = { |
| @@ -123,10 +201,6 @@ static struct regmap_config da9063_regmap_config = { | |||
| 123 | .max_register = DA9063_REG_CHIP_VARIANT, | 201 | .max_register = DA9063_REG_CHIP_VARIANT, |
| 124 | 202 | ||
| 125 | .cache_type = REGCACHE_RBTREE, | 203 | .cache_type = REGCACHE_RBTREE, |
| 126 | |||
| 127 | .rd_table = &da9063_readable_table, | ||
| 128 | .wr_table = &da9063_writeable_table, | ||
| 129 | .volatile_table = &da9063_volatile_table, | ||
| 130 | }; | 204 | }; |
| 131 | 205 | ||
| 132 | static int da9063_i2c_probe(struct i2c_client *i2c, | 206 | static int da9063_i2c_probe(struct i2c_client *i2c, |
| @@ -143,6 +217,16 @@ static int da9063_i2c_probe(struct i2c_client *i2c, | |||
| 143 | da9063->dev = &i2c->dev; | 217 | da9063->dev = &i2c->dev; |
| 144 | da9063->chip_irq = i2c->irq; | 218 | da9063->chip_irq = i2c->irq; |
| 145 | 219 | ||
| 220 | if (da9063->variant_code == PMIC_DA9063_AD) { | ||
| 221 | da9063_regmap_config.rd_table = &da9063_ad_readable_table; | ||
| 222 | da9063_regmap_config.wr_table = &da9063_ad_writeable_table; | ||
| 223 | da9063_regmap_config.volatile_table = &da9063_ad_volatile_table; | ||
| 224 | } else { | ||
| 225 | da9063_regmap_config.rd_table = &da9063_bb_readable_table; | ||
| 226 | da9063_regmap_config.wr_table = &da9063_bb_writeable_table; | ||
| 227 | da9063_regmap_config.volatile_table = &da9063_bb_volatile_table; | ||
| 228 | } | ||
| 229 | |||
| 146 | da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config); | 230 | da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config); |
| 147 | if (IS_ERR(da9063->regmap)) { | 231 | if (IS_ERR(da9063->regmap)) { |
| 148 | ret = PTR_ERR(da9063->regmap); | 232 | ret = PTR_ERR(da9063->regmap); |
diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c index 595393098b09..731ed1a97f59 100644 --- a/drivers/rtc/rtc-da9063.c +++ b/drivers/rtc/rtc-da9063.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | #define YEARS_FROM_DA9063(year) ((year) + 100) | 29 | #define YEARS_FROM_DA9063(year) ((year) + 100) |
| 30 | #define MONTHS_FROM_DA9063(month) ((month) - 1) | 30 | #define MONTHS_FROM_DA9063(month) ((month) - 1) |
| 31 | 31 | ||
| 32 | #define RTC_ALARM_DATA_LEN (DA9063_AD_REG_ALARM_Y - DA9063_AD_REG_ALARM_MI + 1) | ||
| 33 | |||
| 32 | #define RTC_DATA_LEN (DA9063_REG_COUNT_Y - DA9063_REG_COUNT_S + 1) | 34 | #define RTC_DATA_LEN (DA9063_REG_COUNT_Y - DA9063_REG_COUNT_S + 1) |
| 33 | #define RTC_SEC 0 | 35 | #define RTC_SEC 0 |
| 34 | #define RTC_MIN 1 | 36 | #define RTC_MIN 1 |
| @@ -42,6 +44,10 @@ struct da9063_rtc { | |||
| 42 | struct da9063 *hw; | 44 | struct da9063 *hw; |
| 43 | struct rtc_time alarm_time; | 45 | struct rtc_time alarm_time; |
| 44 | bool rtc_sync; | 46 | bool rtc_sync; |
| 47 | int alarm_year; | ||
| 48 | int alarm_start; | ||
| 49 | int alarm_len; | ||
| 50 | int data_start; | ||
| 45 | }; | 51 | }; |
| 46 | 52 | ||
| 47 | static void da9063_data_to_tm(u8 *data, struct rtc_time *tm) | 53 | static void da9063_data_to_tm(u8 *data, struct rtc_time *tm) |
| @@ -83,7 +89,7 @@ static int da9063_rtc_stop_alarm(struct device *dev) | |||
| 83 | { | 89 | { |
| 84 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | 90 | struct da9063_rtc *rtc = dev_get_drvdata(dev); |
| 85 | 91 | ||
| 86 | return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | 92 | return regmap_update_bits(rtc->hw->regmap, rtc->alarm_year, |
| 87 | DA9063_ALARM_ON, 0); | 93 | DA9063_ALARM_ON, 0); |
| 88 | } | 94 | } |
| 89 | 95 | ||
| @@ -91,7 +97,7 @@ static int da9063_rtc_start_alarm(struct device *dev) | |||
| 91 | { | 97 | { |
| 92 | struct da9063_rtc *rtc = dev_get_drvdata(dev); | 98 | struct da9063_rtc *rtc = dev_get_drvdata(dev); |
| 93 | 99 | ||
| 94 | return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | 100 | return regmap_update_bits(rtc->hw->regmap, rtc->alarm_year, |
| 95 | DA9063_ALARM_ON, DA9063_ALARM_ON); | 101 | DA9063_ALARM_ON, DA9063_ALARM_ON); |
| 96 | } | 102 | } |
| 97 | 103 | ||
| @@ -151,8 +157,9 @@ static int da9063_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 151 | int ret; | 157 | int ret; |
| 152 | unsigned int val; | 158 | unsigned int val; |
| 153 | 159 | ||
| 154 | ret = regmap_bulk_read(rtc->hw->regmap, DA9063_REG_ALARM_S, | 160 | data[RTC_SEC] = 0; |
| 155 | &data[RTC_SEC], RTC_DATA_LEN); | 161 | ret = regmap_bulk_read(rtc->hw->regmap, rtc->alarm_start, |
| 162 | &data[rtc->data_start], rtc->alarm_len); | ||
| 156 | if (ret < 0) | 163 | if (ret < 0) |
| 157 | return ret; | 164 | return ret; |
| 158 | 165 | ||
| @@ -186,14 +193,14 @@ static int da9063_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
| 186 | return ret; | 193 | return ret; |
| 187 | } | 194 | } |
| 188 | 195 | ||
| 189 | ret = regmap_bulk_write(rtc->hw->regmap, DA9063_REG_ALARM_S, | 196 | ret = regmap_bulk_write(rtc->hw->regmap, rtc->alarm_start, |
| 190 | data, RTC_DATA_LEN); | 197 | &data[rtc->data_start], rtc->alarm_len); |
| 191 | if (ret < 0) { | 198 | if (ret < 0) { |
| 192 | dev_err(dev, "Failed to write alarm: %d\n", ret); | 199 | dev_err(dev, "Failed to write alarm: %d\n", ret); |
| 193 | return ret; | 200 | return ret; |
| 194 | } | 201 | } |
| 195 | 202 | ||
| 196 | rtc->alarm_time = alrm->time; | 203 | da9063_data_to_tm(data, &rtc->alarm_time); |
| 197 | 204 | ||
| 198 | if (alrm->enabled) { | 205 | if (alrm->enabled) { |
| 199 | ret = da9063_rtc_start_alarm(dev); | 206 | ret = da9063_rtc_start_alarm(dev); |
| @@ -218,7 +225,7 @@ static irqreturn_t da9063_alarm_event(int irq, void *data) | |||
| 218 | { | 225 | { |
| 219 | struct da9063_rtc *rtc = data; | 226 | struct da9063_rtc *rtc = data; |
| 220 | 227 | ||
| 221 | regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y, | 228 | regmap_update_bits(rtc->hw->regmap, rtc->alarm_year, |
| 222 | DA9063_ALARM_ON, 0); | 229 | DA9063_ALARM_ON, 0); |
| 223 | 230 | ||
| 224 | rtc->rtc_sync = true; | 231 | rtc->rtc_sync = true; |
| @@ -257,7 +264,23 @@ static int da9063_rtc_probe(struct platform_device *pdev) | |||
| 257 | goto err; | 264 | goto err; |
| 258 | } | 265 | } |
| 259 | 266 | ||
| 260 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_S, | 267 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); |
| 268 | if (!rtc) | ||
| 269 | return -ENOMEM; | ||
| 270 | |||
| 271 | if (da9063->variant_code == PMIC_DA9063_AD) { | ||
| 272 | rtc->alarm_year = DA9063_AD_REG_ALARM_Y; | ||
| 273 | rtc->alarm_start = DA9063_AD_REG_ALARM_MI; | ||
| 274 | rtc->alarm_len = RTC_ALARM_DATA_LEN; | ||
| 275 | rtc->data_start = RTC_MIN; | ||
| 276 | } else { | ||
| 277 | rtc->alarm_year = DA9063_BB_REG_ALARM_Y; | ||
| 278 | rtc->alarm_start = DA9063_BB_REG_ALARM_S; | ||
| 279 | rtc->alarm_len = RTC_DATA_LEN; | ||
| 280 | rtc->data_start = RTC_SEC; | ||
| 281 | } | ||
| 282 | |||
| 283 | ret = regmap_update_bits(da9063->regmap, rtc->alarm_start, | ||
| 261 | DA9063_ALARM_STATUS_TICK | DA9063_ALARM_STATUS_ALARM, | 284 | DA9063_ALARM_STATUS_TICK | DA9063_ALARM_STATUS_ALARM, |
| 262 | 0); | 285 | 0); |
| 263 | if (ret < 0) { | 286 | if (ret < 0) { |
| @@ -265,7 +288,7 @@ static int da9063_rtc_probe(struct platform_device *pdev) | |||
| 265 | goto err; | 288 | goto err; |
| 266 | } | 289 | } |
| 267 | 290 | ||
| 268 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_S, | 291 | ret = regmap_update_bits(da9063->regmap, rtc->alarm_start, |
| 269 | DA9063_ALARM_STATUS_ALARM, | 292 | DA9063_ALARM_STATUS_ALARM, |
| 270 | DA9063_ALARM_STATUS_ALARM); | 293 | DA9063_ALARM_STATUS_ALARM); |
| 271 | if (ret < 0) { | 294 | if (ret < 0) { |
| @@ -273,25 +296,22 @@ static int da9063_rtc_probe(struct platform_device *pdev) | |||
| 273 | goto err; | 296 | goto err; |
| 274 | } | 297 | } |
| 275 | 298 | ||
| 276 | ret = regmap_update_bits(da9063->regmap, DA9063_REG_ALARM_Y, | 299 | ret = regmap_update_bits(da9063->regmap, rtc->alarm_year, |
| 277 | DA9063_TICK_ON, 0); | 300 | DA9063_TICK_ON, 0); |
| 278 | if (ret < 0) { | 301 | if (ret < 0) { |
| 279 | dev_err(&pdev->dev, "Failed to disable TICKs\n"); | 302 | dev_err(&pdev->dev, "Failed to disable TICKs\n"); |
| 280 | goto err; | 303 | goto err; |
| 281 | } | 304 | } |
| 282 | 305 | ||
| 283 | ret = regmap_bulk_read(da9063->regmap, DA9063_REG_ALARM_S, | 306 | data[RTC_SEC] = 0; |
| 284 | data, RTC_DATA_LEN); | 307 | ret = regmap_bulk_read(da9063->regmap, rtc->alarm_start, |
| 308 | &data[rtc->data_start], rtc->alarm_len); | ||
| 285 | if (ret < 0) { | 309 | if (ret < 0) { |
| 286 | dev_err(&pdev->dev, "Failed to read initial alarm data: %d\n", | 310 | dev_err(&pdev->dev, "Failed to read initial alarm data: %d\n", |
| 287 | ret); | 311 | ret); |
| 288 | goto err; | 312 | goto err; |
| 289 | } | 313 | } |
| 290 | 314 | ||
| 291 | rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); | ||
| 292 | if (!rtc) | ||
| 293 | return -ENOMEM; | ||
| 294 | |||
| 295 | platform_set_drvdata(pdev, rtc); | 315 | platform_set_drvdata(pdev, rtc); |
| 296 | 316 | ||
| 297 | irq_alarm = platform_get_irq_byname(pdev, "ALARM"); | 317 | irq_alarm = platform_get_irq_byname(pdev, "ALARM"); |
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h index 00a9aac5d1e8..b92a3262f8f6 100644 --- a/include/linux/mfd/da9063/core.h +++ b/include/linux/mfd/da9063/core.h | |||
| @@ -34,7 +34,8 @@ enum da9063_models { | |||
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | enum da9063_variant_codes { | 36 | enum da9063_variant_codes { |
| 37 | PMIC_DA9063_BB = 0x5 | 37 | PMIC_DA9063_AD = 0x3, |
| 38 | PMIC_DA9063_BB = 0x5, | ||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | /* Interrupts */ | 41 | /* Interrupts */ |
diff --git a/include/linux/mfd/da9063/registers.h b/include/linux/mfd/da9063/registers.h index 09a85c699da1..2e0ba6d5fbc3 100644 --- a/include/linux/mfd/da9063/registers.h +++ b/include/linux/mfd/da9063/registers.h | |||
| @@ -104,16 +104,27 @@ | |||
| 104 | #define DA9063_REG_COUNT_D 0x43 | 104 | #define DA9063_REG_COUNT_D 0x43 |
| 105 | #define DA9063_REG_COUNT_MO 0x44 | 105 | #define DA9063_REG_COUNT_MO 0x44 |
| 106 | #define DA9063_REG_COUNT_Y 0x45 | 106 | #define DA9063_REG_COUNT_Y 0x45 |
| 107 | #define DA9063_REG_ALARM_S 0x46 | 107 | |
| 108 | #define DA9063_REG_ALARM_MI 0x47 | 108 | #define DA9063_AD_REG_ALARM_MI 0x46 |
| 109 | #define DA9063_REG_ALARM_H 0x48 | 109 | #define DA9063_AD_REG_ALARM_H 0x47 |
| 110 | #define DA9063_REG_ALARM_D 0x49 | 110 | #define DA9063_AD_REG_ALARM_D 0x48 |
| 111 | #define DA9063_REG_ALARM_MO 0x4A | 111 | #define DA9063_AD_REG_ALARM_MO 0x49 |
| 112 | #define DA9063_REG_ALARM_Y 0x4B | 112 | #define DA9063_AD_REG_ALARM_Y 0x4A |
| 113 | #define DA9063_REG_SECOND_A 0x4C | 113 | #define DA9063_AD_REG_SECOND_A 0x4B |
| 114 | #define DA9063_REG_SECOND_B 0x4D | 114 | #define DA9063_AD_REG_SECOND_B 0x4C |
| 115 | #define DA9063_REG_SECOND_C 0x4E | 115 | #define DA9063_AD_REG_SECOND_C 0x4D |
| 116 | #define DA9063_REG_SECOND_D 0x4F | 116 | #define DA9063_AD_REG_SECOND_D 0x4E |
| 117 | |||
| 118 | #define DA9063_BB_REG_ALARM_S 0x46 | ||
| 119 | #define DA9063_BB_REG_ALARM_MI 0x47 | ||
| 120 | #define DA9063_BB_REG_ALARM_H 0x48 | ||
| 121 | #define DA9063_BB_REG_ALARM_D 0x49 | ||
| 122 | #define DA9063_BB_REG_ALARM_MO 0x4A | ||
| 123 | #define DA9063_BB_REG_ALARM_Y 0x4B | ||
| 124 | #define DA9063_BB_REG_SECOND_A 0x4C | ||
| 125 | #define DA9063_BB_REG_SECOND_B 0x4D | ||
| 126 | #define DA9063_BB_REG_SECOND_C 0x4E | ||
| 127 | #define DA9063_BB_REG_SECOND_D 0x4F | ||
| 117 | 128 | ||
| 118 | /* Sequencer Control Registers */ | 129 | /* Sequencer Control Registers */ |
| 119 | #define DA9063_REG_SEQ 0x81 | 130 | #define DA9063_REG_SEQ 0x81 |
| @@ -223,37 +234,67 @@ | |||
| 223 | #define DA9063_REG_CONFIG_J 0x10F | 234 | #define DA9063_REG_CONFIG_J 0x10F |
| 224 | #define DA9063_REG_CONFIG_K 0x110 | 235 | #define DA9063_REG_CONFIG_K 0x110 |
| 225 | #define DA9063_REG_CONFIG_L 0x111 | 236 | #define DA9063_REG_CONFIG_L 0x111 |
| 226 | #define DA9063_REG_CONFIG_M 0x112 | 237 | |
| 227 | #define DA9063_REG_CONFIG_N 0x113 | 238 | #define DA9063_AD_REG_MON_REG_1 0x112 |
| 228 | 239 | #define DA9063_AD_REG_MON_REG_2 0x113 | |
| 229 | #define DA9063_REG_MON_REG_1 0x114 | 240 | #define DA9063_AD_REG_MON_REG_3 0x114 |
| 230 | #define DA9063_REG_MON_REG_2 0x115 | 241 | #define DA9063_AD_REG_MON_REG_4 0x115 |
| 231 | #define DA9063_REG_MON_REG_3 0x116 | 242 | #define DA9063_AD_REG_MON_REG_5 0x116 |
| 232 | #define DA9063_REG_MON_REG_4 0x117 | 243 | #define DA9063_AD_REG_MON_REG_6 0x117 |
| 233 | #define DA9063_REG_MON_REG_5 0x11E | 244 | #define DA9063_AD_REG_TRIM_CLDR 0x118 |
| 234 | #define DA9063_REG_MON_REG_6 0x11F | 245 | |
| 235 | #define DA9063_REG_TRIM_CLDR 0x120 | 246 | #define DA9063_AD_REG_GP_ID_0 0x119 |
| 247 | #define DA9063_AD_REG_GP_ID_1 0x11A | ||
| 248 | #define DA9063_AD_REG_GP_ID_2 0x11B | ||
| 249 | #define DA9063_AD_REG_GP_ID_3 0x11C | ||
| 250 | #define DA9063_AD_REG_GP_ID_4 0x11D | ||
| 251 | #define DA9063_AD_REG_GP_ID_5 0x11E | ||
| 252 | #define DA9063_AD_REG_GP_ID_6 0x11F | ||
| 253 | #define DA9063_AD_REG_GP_ID_7 0x120 | ||
| 254 | #define DA9063_AD_REG_GP_ID_8 0x121 | ||
| 255 | #define DA9063_AD_REG_GP_ID_9 0x122 | ||
| 256 | #define DA9063_AD_REG_GP_ID_10 0x123 | ||
| 257 | #define DA9063_AD_REG_GP_ID_11 0x124 | ||
| 258 | #define DA9063_AD_REG_GP_ID_12 0x125 | ||
| 259 | #define DA9063_AD_REG_GP_ID_13 0x126 | ||
| 260 | #define DA9063_AD_REG_GP_ID_14 0x127 | ||
| 261 | #define DA9063_AD_REG_GP_ID_15 0x128 | ||
| 262 | #define DA9063_AD_REG_GP_ID_16 0x129 | ||
| 263 | #define DA9063_AD_REG_GP_ID_17 0x12A | ||
| 264 | #define DA9063_AD_REG_GP_ID_18 0x12B | ||
| 265 | #define DA9063_AD_REG_GP_ID_19 0x12C | ||
| 266 | |||
| 267 | #define DA9063_BB_REG_CONFIG_M 0x112 | ||
| 268 | #define DA9063_BB_REG_CONFIG_N 0x113 | ||
| 269 | |||
| 270 | #define DA9063_BB_REG_MON_REG_1 0x114 | ||
| 271 | #define DA9063_BB_REG_MON_REG_2 0x115 | ||
| 272 | #define DA9063_BB_REG_MON_REG_3 0x116 | ||
| 273 | #define DA9063_BB_REG_MON_REG_4 0x117 | ||
| 274 | #define DA9063_BB_REG_MON_REG_5 0x11E | ||
| 275 | #define DA9063_BB_REG_MON_REG_6 0x11F | ||
| 276 | #define DA9063_BB_REG_TRIM_CLDR 0x120 | ||
| 236 | /* General Purpose Registers */ | 277 | /* General Purpose Registers */ |
| 237 | #define DA9063_REG_GP_ID_0 0x121 | 278 | #define DA9063_BB_REG_GP_ID_0 0x121 |
| 238 | #define DA9063_REG_GP_ID_1 0x122 | 279 | #define DA9063_BB_REG_GP_ID_1 0x122 |
| 239 | #define DA9063_REG_GP_ID_2 0x123 | 280 | #define DA9063_BB_REG_GP_ID_2 0x123 |
| 240 | #define DA9063_REG_GP_ID_3 0x124 | 281 | #define DA9063_BB_REG_GP_ID_3 0x124 |
| 241 | #define DA9063_REG_GP_ID_4 0x125 | 282 | #define DA9063_BB_REG_GP_ID_4 0x125 |
| 242 | #define DA9063_REG_GP_ID_5 0x126 | 283 | #define DA9063_BB_REG_GP_ID_5 0x126 |
| 243 | #define DA9063_REG_GP_ID_6 0x127 | 284 | #define DA9063_BB_REG_GP_ID_6 0x127 |
| 244 | #define DA9063_REG_GP_ID_7 0x128 | 285 | #define DA9063_BB_REG_GP_ID_7 0x128 |
| 245 | #define DA9063_REG_GP_ID_8 0x129 | 286 | #define DA9063_BB_REG_GP_ID_8 0x129 |
| 246 | #define DA9063_REG_GP_ID_9 0x12A | 287 | #define DA9063_BB_REG_GP_ID_9 0x12A |
| 247 | #define DA9063_REG_GP_ID_10 0x12B | 288 | #define DA9063_BB_REG_GP_ID_10 0x12B |
| 248 | #define DA9063_REG_GP_ID_11 0x12C | 289 | #define DA9063_BB_REG_GP_ID_11 0x12C |
| 249 | #define DA9063_REG_GP_ID_12 0x12D | 290 | #define DA9063_BB_REG_GP_ID_12 0x12D |
| 250 | #define DA9063_REG_GP_ID_13 0x12E | 291 | #define DA9063_BB_REG_GP_ID_13 0x12E |
| 251 | #define DA9063_REG_GP_ID_14 0x12F | 292 | #define DA9063_BB_REG_GP_ID_14 0x12F |
| 252 | #define DA9063_REG_GP_ID_15 0x130 | 293 | #define DA9063_BB_REG_GP_ID_15 0x130 |
| 253 | #define DA9063_REG_GP_ID_16 0x131 | 294 | #define DA9063_BB_REG_GP_ID_16 0x131 |
| 254 | #define DA9063_REG_GP_ID_17 0x132 | 295 | #define DA9063_BB_REG_GP_ID_17 0x132 |
| 255 | #define DA9063_REG_GP_ID_18 0x133 | 296 | #define DA9063_BB_REG_GP_ID_18 0x133 |
| 256 | #define DA9063_REG_GP_ID_19 0x134 | 297 | #define DA9063_BB_REG_GP_ID_19 0x134 |
| 257 | 298 | ||
| 258 | /* Chip ID and variant */ | 299 | /* Chip ID and variant */ |
| 259 | #define DA9063_REG_CHIP_ID 0x181 | 300 | #define DA9063_REG_CHIP_ID 0x181 |
| @@ -404,10 +445,10 @@ | |||
| 404 | /* DA9063_REG_CONTROL_B (addr=0x0F) */ | 445 | /* DA9063_REG_CONTROL_B (addr=0x0F) */ |
| 405 | #define DA9063_CHG_SEL 0x01 | 446 | #define DA9063_CHG_SEL 0x01 |
| 406 | #define DA9063_WATCHDOG_PD 0x02 | 447 | #define DA9063_WATCHDOG_PD 0x02 |
| 407 | #define DA9063_RESET_BLINKING 0x04 | 448 | #define DA9063_BB_RESET_BLINKING 0x04 |
| 408 | #define DA9063_NRES_MODE 0x08 | 449 | #define DA9063_NRES_MODE 0x08 |
| 409 | #define DA9063_NONKEY_LOCK 0x10 | 450 | #define DA9063_NONKEY_LOCK 0x10 |
| 410 | #define DA9063_BUCK_SLOWSTART 0x80 | 451 | #define DA9063_BB_BUCK_SLOWSTART 0x80 |
| 411 | 452 | ||
| 412 | /* DA9063_REG_CONTROL_C (addr=0x10) */ | 453 | /* DA9063_REG_CONTROL_C (addr=0x10) */ |
| 413 | #define DA9063_DEBOUNCING_MASK 0x07 | 454 | #define DA9063_DEBOUNCING_MASK 0x07 |
| @@ -467,7 +508,7 @@ | |||
| 467 | #define DA9063_GPADC_PAUSE 0x02 | 508 | #define DA9063_GPADC_PAUSE 0x02 |
| 468 | #define DA9063_PMIF_DIS 0x04 | 509 | #define DA9063_PMIF_DIS 0x04 |
| 469 | #define DA9063_HS2WIRE_DIS 0x08 | 510 | #define DA9063_HS2WIRE_DIS 0x08 |
| 470 | #define DA9063_CLDR_PAUSE 0x10 | 511 | #define DA9063_BB_CLDR_PAUSE 0x10 |
| 471 | #define DA9063_BBAT_DIS 0x20 | 512 | #define DA9063_BBAT_DIS 0x20 |
| 472 | #define DA9063_OUT_32K_PAUSE 0x40 | 513 | #define DA9063_OUT_32K_PAUSE 0x40 |
| 473 | #define DA9063_PMCONT_DIS 0x80 | 514 | #define DA9063_PMCONT_DIS 0x80 |
| @@ -844,7 +885,7 @@ | |||
| 844 | #define DA9063_MONITOR 0x40 | 885 | #define DA9063_MONITOR 0x40 |
| 845 | 886 | ||
| 846 | /* DA9063_REG_ALARM_S (addr=0x46) */ | 887 | /* DA9063_REG_ALARM_S (addr=0x46) */ |
| 847 | #define DA9063_ALARM_S_MASK 0x3F | 888 | #define DA9063_BB_ALARM_S_MASK 0x3F |
| 848 | #define DA9063_ALARM_STATUS_ALARM 0x80 | 889 | #define DA9063_ALARM_STATUS_ALARM 0x80 |
| 849 | #define DA9063_ALARM_STATUS_TICK 0x40 | 890 | #define DA9063_ALARM_STATUS_TICK 0x40 |
| 850 | /* DA9063_REG_ALARM_MI (addr=0x47) */ | 891 | /* DA9063_REG_ALARM_MI (addr=0x47) */ |
