aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-04-13 00:46:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-15 14:04:07 -0400
commit31815c08fc90f44d6165034fd473f23df5d31449 (patch)
tree48be647acdf3b2e04268099739e1a29a13f1bac5
parent289b8dd695836fc295cf3cb4e1e520322495556c (diff)
serial: sccnxp: Replace pdata.init/exit with regulator API
Typical usage of pdata.init/exit is enable/disable power and/or toggle reset for the target chip. This patch replaces these callbacks with regulator API. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/sccnxp.c21
-rw-r--r--include/linux/platform_data/serial-sccnxp.h4
2 files changed, 15 insertions, 10 deletions
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index b1d04aabd50c..c77304155410 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -27,6 +27,7 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/platform_data/serial-sccnxp.h> 29#include <linux/platform_data/serial-sccnxp.h>
30#include <linux/regulator/consumer.h>
30 31
31#define SCCNXP_NAME "uart-sccnxp" 32#define SCCNXP_NAME "uart-sccnxp"
32#define SCCNXP_MAJOR 204 33#define SCCNXP_MAJOR 204
@@ -131,6 +132,8 @@ struct sccnxp_port {
131 struct timer_list timer; 132 struct timer_list timer;
132 133
133 struct sccnxp_pdata pdata; 134 struct sccnxp_pdata pdata;
135
136 struct regulator *regulator;
134}; 137};
135 138
136static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift) 139static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift)
@@ -916,6 +919,16 @@ static int sccnxp_probe(struct platform_device *pdev)
916 goto err_out; 919 goto err_out;
917 } 920 }
918 921
922 s->regulator = devm_regulator_get(&pdev->dev, "VCC");
923 if (!IS_ERR(s->regulator)) {
924 ret = regulator_enable(s->regulator);
925 if (ret) {
926 dev_err(&pdev->dev,
927 "Failed to enable regulator: %i\n", ret);
928 return ret;
929 }
930 }
931
919 membase = devm_ioremap_resource(&pdev->dev, res); 932 membase = devm_ioremap_resource(&pdev->dev, res);
920 if (IS_ERR(membase)) { 933 if (IS_ERR(membase)) {
921 ret = PTR_ERR(membase); 934 ret = PTR_ERR(membase);
@@ -965,10 +978,6 @@ static int sccnxp_probe(struct platform_device *pdev)
965 s->imr = 0; 978 s->imr = 0;
966 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0); 979 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0);
967 980
968 /* Board specific configure */
969 if (s->pdata.init)
970 s->pdata.init();
971
972 if (!s->poll) { 981 if (!s->poll) {
973 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, 982 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL,
974 sccnxp_ist, 983 sccnxp_ist,
@@ -1009,8 +1018,8 @@ static int sccnxp_remove(struct platform_device *pdev)
1009 uart_unregister_driver(&s->uart); 1018 uart_unregister_driver(&s->uart);
1010 platform_set_drvdata(pdev, NULL); 1019 platform_set_drvdata(pdev, NULL);
1011 1020
1012 if (s->pdata.exit) 1021 if (!IS_ERR(s->regulator))
1013 s->pdata.exit(); 1022 return regulator_disable(s->regulator);
1014 1023
1015 return 0; 1024 return 0;
1016} 1025}
diff --git a/include/linux/platform_data/serial-sccnxp.h b/include/linux/platform_data/serial-sccnxp.h
index 215574d1e81d..bdc510d03245 100644
--- a/include/linux/platform_data/serial-sccnxp.h
+++ b/include/linux/platform_data/serial-sccnxp.h
@@ -86,10 +86,6 @@ struct sccnxp_pdata {
86 const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; 86 const u32 mctrl_cfg[SCCNXP_MAX_UARTS];
87 /* Timer value for polling mode (usecs) */ 87 /* Timer value for polling mode (usecs) */
88 const unsigned int poll_time_us; 88 const unsigned int poll_time_us;
89 /* Called during startup */
90 void (*init)(void);
91 /* Called before finish */
92 void (*exit)(void);
93}; 89};
94 90
95#endif 91#endif