mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
DaVinci GPIO driver updates
---------------------------
This pull request contains updates
to DaVinci GPIO driver and the
resultant platform code changes. The
updates include DT-conversion and
changes to make the driver cross-platform
ready.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQIcBAABAgAGBQJSuycQAAoJEGFBu2jqvgRNIdMP/jE7LW16dF2dGq79Gy26GWcM
dNSSXzwEm2q5vT49H8ADzkbnsI2PlFpcH0mwn5BpPuVRl+RKHfNEZxwuAthqKduu
BIKVGBkNECrliIIUecCwBjAYpQknynvLAGHRhYmibEnZCH45kZ8g7DLJMeBL4Huz
smDkz2yWWoHjnIaCk/kIbQfeETKSx5GP+OwnnrU/4HPpndxqZ6KU/MXb8ZeMiLfa
piMl10o/YIJcfZcKBbkI1I2PuHNgNAzjVnMMsCVF+B5vgLiYmj9P+6l1Sfau6y8A
kimW34q4HNuQ07hkDAIALz0AH7y8bL9SoKprT4NX10DvGHwl21a/Ji5QS8N49krM
+HAiSIUdsFwie5M8286owGAJ/TBFReStWY1a/sIghx9idU6ejuM/Pj8/bfTS+Vu+
8wyos8hTYVBDOEwoRzw48S5x93U5W6dsjOacOJ+blHBtPmADlWSNG8HwzSfWxHEI
PMaVhu2EKtgD1ZFgU5Zlt+f5h3E4ezAIEpiPIhdLcg/3hqNSpFRmNV3nJsx+KwE+
JyZXcHkyq42i6wL5Sdf6W/Dpd5knPyqP3BBWBTeg+BDLnH8F2+Vtws95I4dlit0T
RtQ9Ms6QmznPTs9fMaviURiVIUBK6XIG5UHDU10bhL0h8vOR/hXAVrAB+wZntvPU
uIXAapK/78LTBX92opDz
=DxLt
-----END PGP SIGNATURE-----
Merge tag 'davinci-for-v3.14/gpio' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into next/drivers
From Sekhar Nori:
DaVinci GPIO driver updates
---------------------------
This pull request contains updates to DaVinci GPIO driver and the
resultant platform code changes. The updates include DT-conversion and
changes to make the driver cross-platform ready.
* tag 'davinci-for-v3.14/gpio' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci:
gpio: davinci: don't create irq_domain in case of unbanked irqs
gpio: davinci: use chained_irq_enter/chained_irq_exit API
gpio: davinci: add OF support
gpio: davinci: remove unused variable intc_irq_num
gpio: davinci: convert to use irqdomain support.
gpio: introduce GPIO_DAVINCI kconfig option
gpio: davinci: get rid of DAVINCI_N_GPIO
gpio: davinci: use {readl|writel}_relaxed() instead of __raw_*
Signed-off-by: Olof Johansson <[email protected]>
This commit is contained in:
commit
a7dedb4fea
816 changed files with 7769 additions and 4046 deletions
|
|
@ -220,6 +220,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|||
|
||||
at91_alarm_year = tm.tm_year;
|
||||
|
||||
tm.tm_mon = alrm->time.tm_mon;
|
||||
tm.tm_mday = alrm->time.tm_mday;
|
||||
tm.tm_hour = alrm->time.tm_hour;
|
||||
tm.tm_min = alrm->time.tm_min;
|
||||
tm.tm_sec = alrm->time.tm_sec;
|
||||
|
|
|
|||
|
|
@ -28,10 +28,20 @@
|
|||
#include <linux/mfd/samsung/irq.h>
|
||||
#include <linux/mfd/samsung/rtc.h>
|
||||
|
||||
/*
|
||||
* Maximum number of retries for checking changes in UDR field
|
||||
* of SEC_RTC_UDR_CON register (to limit possible endless loop).
|
||||
*
|
||||
* After writing to RTC registers (setting time or alarm) read the UDR field
|
||||
* in SEC_RTC_UDR_CON register. UDR is auto-cleared when data have
|
||||
* been transferred.
|
||||
*/
|
||||
#define UDR_READ_RETRY_CNT 5
|
||||
|
||||
struct s5m_rtc_info {
|
||||
struct device *dev;
|
||||
struct sec_pmic_dev *s5m87xx;
|
||||
struct regmap *rtc;
|
||||
struct regmap *regmap;
|
||||
struct rtc_device *rtc_dev;
|
||||
int irq;
|
||||
int device_type;
|
||||
|
|
@ -84,12 +94,31 @@ static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read RTC_UDR_CON register and wait till UDR field is cleared.
|
||||
* This indicates that time/alarm update ended.
|
||||
*/
|
||||
static inline int s5m8767_wait_for_udr_update(struct s5m_rtc_info *info)
|
||||
{
|
||||
int ret, retry = UDR_READ_RETRY_CNT;
|
||||
unsigned int data;
|
||||
|
||||
do {
|
||||
ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
|
||||
} while (--retry && (data & RTC_UDR_MASK) && !ret);
|
||||
|
||||
if (!retry)
|
||||
dev_err(info->dev, "waiting for UDR update, reached max number of retries\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info)
|
||||
{
|
||||
int ret;
|
||||
unsigned int data;
|
||||
|
||||
ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
|
||||
ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "failed to read update reg(%d)\n", ret);
|
||||
return ret;
|
||||
|
|
@ -98,15 +127,13 @@ static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info)
|
|||
data |= RTC_TIME_EN_MASK;
|
||||
data |= RTC_UDR_MASK;
|
||||
|
||||
ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data);
|
||||
ret = regmap_write(info->regmap, SEC_RTC_UDR_CON, data);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "failed to write update reg(%d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
|
||||
} while ((data & RTC_UDR_MASK) && !ret);
|
||||
ret = s5m8767_wait_for_udr_update(info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -116,7 +143,7 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
|
|||
int ret;
|
||||
unsigned int data;
|
||||
|
||||
ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
|
||||
ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "%s: fail to read update reg(%d)\n",
|
||||
__func__, ret);
|
||||
|
|
@ -126,16 +153,14 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
|
|||
data &= ~RTC_TIME_EN_MASK;
|
||||
data |= RTC_UDR_MASK;
|
||||
|
||||
ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data);
|
||||
ret = regmap_write(info->regmap, SEC_RTC_UDR_CON, data);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "%s: fail to write update reg(%d)\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
|
||||
} while ((data & RTC_UDR_MASK) && !ret);
|
||||
ret = s5m8767_wait_for_udr_update(info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -178,7 +203,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|||
u8 data[8];
|
||||
int ret;
|
||||
|
||||
ret = regmap_bulk_read(info->rtc, SEC_RTC_SEC, data, 8);
|
||||
ret = regmap_bulk_read(info->regmap, SEC_RTC_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -226,7 +251,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
|
||||
|
||||
ret = regmap_raw_write(info->rtc, SEC_RTC_SEC, data, 8);
|
||||
ret = regmap_raw_write(info->regmap, SEC_RTC_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -242,20 +267,20 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|||
unsigned int val;
|
||||
int ret, i;
|
||||
|
||||
ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
switch (info->device_type) {
|
||||
case S5M8763X:
|
||||
s5m8763_data_to_tm(data, &alrm->time);
|
||||
ret = regmap_read(info->rtc, SEC_ALARM0_CONF, &val);
|
||||
ret = regmap_read(info->regmap, SEC_ALARM0_CONF, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
alrm->enabled = !!val;
|
||||
|
||||
ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val);
|
||||
ret = regmap_read(info->regmap, SEC_RTC_STATUS, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -278,7 +303,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|||
}
|
||||
|
||||
alrm->pending = 0;
|
||||
ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val);
|
||||
ret = regmap_read(info->regmap, SEC_RTC_STATUS, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
break;
|
||||
|
|
@ -301,7 +326,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
|
|||
int ret, i;
|
||||
struct rtc_time tm;
|
||||
|
||||
ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -312,14 +337,14 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
|
|||
|
||||
switch (info->device_type) {
|
||||
case S5M8763X:
|
||||
ret = regmap_write(info->rtc, SEC_ALARM0_CONF, 0);
|
||||
ret = regmap_write(info->regmap, SEC_ALARM0_CONF, 0);
|
||||
break;
|
||||
|
||||
case S5M8767X:
|
||||
for (i = 0; i < 7; i++)
|
||||
data[i] &= ~ALARM_ENABLE_MASK;
|
||||
|
||||
ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -341,7 +366,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
|
|||
u8 alarm0_conf;
|
||||
struct rtc_time tm;
|
||||
|
||||
ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -353,7 +378,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
|
|||
switch (info->device_type) {
|
||||
case S5M8763X:
|
||||
alarm0_conf = 0x77;
|
||||
ret = regmap_write(info->rtc, SEC_ALARM0_CONF, alarm0_conf);
|
||||
ret = regmap_write(info->regmap, SEC_ALARM0_CONF, alarm0_conf);
|
||||
break;
|
||||
|
||||
case S5M8767X:
|
||||
|
|
@ -368,7 +393,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
|
|||
if (data[RTC_YEAR1] & 0x7f)
|
||||
data[RTC_YEAR1] |= ALARM_ENABLE_MASK;
|
||||
|
||||
ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = s5m8767_rtc_set_alarm_reg(info);
|
||||
|
|
@ -410,7 +435,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8);
|
||||
ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -455,7 +480,7 @@ static const struct rtc_class_ops s5m_rtc_ops = {
|
|||
static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable)
|
||||
{
|
||||
int ret;
|
||||
ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL,
|
||||
ret = regmap_update_bits(info->regmap, SEC_WTSR_SMPL_CNTL,
|
||||
WTSR_ENABLE_MASK,
|
||||
enable ? WTSR_ENABLE_MASK : 0);
|
||||
if (ret < 0)
|
||||
|
|
@ -466,7 +491,7 @@ static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable)
|
|||
static void s5m_rtc_enable_smpl(struct s5m_rtc_info *info, bool enable)
|
||||
{
|
||||
int ret;
|
||||
ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL,
|
||||
ret = regmap_update_bits(info->regmap, SEC_WTSR_SMPL_CNTL,
|
||||
SMPL_ENABLE_MASK,
|
||||
enable ? SMPL_ENABLE_MASK : 0);
|
||||
if (ret < 0)
|
||||
|
|
@ -481,7 +506,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
|
|||
int ret;
|
||||
struct rtc_time tm;
|
||||
|
||||
ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &tp_read);
|
||||
ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &tp_read);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "%s: fail to read control reg(%d)\n",
|
||||
__func__, ret);
|
||||
|
|
@ -493,7 +518,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
|
|||
data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
|
||||
|
||||
info->rtc_24hr_mode = 1;
|
||||
ret = regmap_raw_write(info->rtc, SEC_ALARM0_CONF, data, 2);
|
||||
ret = regmap_raw_write(info->regmap, SEC_ALARM0_CONF, data, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(info->dev, "%s: fail to write controlm reg(%d)\n",
|
||||
__func__, ret);
|
||||
|
|
@ -515,7 +540,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
|
|||
ret = s5m_rtc_set_time(info->dev, &tm);
|
||||
}
|
||||
|
||||
ret = regmap_update_bits(info->rtc, SEC_RTC_UDR_CON,
|
||||
ret = regmap_update_bits(info->regmap, SEC_RTC_UDR_CON,
|
||||
RTC_TCON_MASK, tp_read | RTC_TCON_MASK);
|
||||
if (ret < 0)
|
||||
dev_err(info->dev, "%s: fail to update TCON reg(%d)\n",
|
||||
|
|
@ -542,17 +567,19 @@ static int s5m_rtc_probe(struct platform_device *pdev)
|
|||
|
||||
info->dev = &pdev->dev;
|
||||
info->s5m87xx = s5m87xx;
|
||||
info->rtc = s5m87xx->rtc;
|
||||
info->regmap = s5m87xx->regmap_rtc;
|
||||
info->device_type = s5m87xx->device_type;
|
||||
info->wtsr_smpl = s5m87xx->wtsr_smpl;
|
||||
|
||||
switch (pdata->device_type) {
|
||||
case S5M8763X:
|
||||
info->irq = s5m87xx->irq_base + S5M8763_IRQ_ALARM0;
|
||||
info->irq = regmap_irq_get_virq(s5m87xx->irq_data,
|
||||
S5M8763_IRQ_ALARM0);
|
||||
break;
|
||||
|
||||
case S5M8767X:
|
||||
info->irq = s5m87xx->irq_base + S5M8767_IRQ_RTCA1;
|
||||
info->irq = regmap_irq_get_virq(s5m87xx->irq_data,
|
||||
S5M8767_IRQ_RTCA1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -596,7 +623,7 @@ static void s5m_rtc_shutdown(struct platform_device *pdev)
|
|||
if (info->wtsr_smpl) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
s5m_rtc_enable_wtsr(info, false);
|
||||
regmap_read(info->rtc, SEC_WTSR_SMPL_CNTL, &val);
|
||||
regmap_read(info->regmap, SEC_WTSR_SMPL_CNTL, &val);
|
||||
pr_debug("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val);
|
||||
if (val & WTSR_ENABLE_MASK)
|
||||
pr_emerg("%s: fail to disable WTSR\n",
|
||||
|
|
@ -612,6 +639,30 @@ static void s5m_rtc_shutdown(struct platform_device *pdev)
|
|||
s5m_rtc_enable_smpl(info, false);
|
||||
}
|
||||
|
||||
static int s5m_rtc_resume(struct device *dev)
|
||||
{
|
||||
struct s5m_rtc_info *info = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
ret = disable_irq_wake(info->irq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int s5m_rtc_suspend(struct device *dev)
|
||||
{
|
||||
struct s5m_rtc_info *info = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
ret = enable_irq_wake(info->irq);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume);
|
||||
|
||||
static const struct platform_device_id s5m_rtc_id[] = {
|
||||
{ "s5m-rtc", 0 },
|
||||
};
|
||||
|
|
@ -620,6 +671,7 @@ static struct platform_driver s5m_rtc_driver = {
|
|||
.driver = {
|
||||
.name = "s5m-rtc",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &s5m_rtc_pm_ops,
|
||||
},
|
||||
.probe = s5m_rtc_probe,
|
||||
.shutdown = s5m_rtc_shutdown,
|
||||
|
|
|
|||
Loading…
Reference in a new issue