Commit 31815c08 authored by Alexander Shiyan's avatar Alexander Shiyan Committed by Greg Kroah-Hartman

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: default avatarAlexander Shiyan <shc_work@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 289b8dd6
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/platform_data/serial-sccnxp.h> #include <linux/platform_data/serial-sccnxp.h>
#include <linux/regulator/consumer.h>
#define SCCNXP_NAME "uart-sccnxp" #define SCCNXP_NAME "uart-sccnxp"
#define SCCNXP_MAJOR 204 #define SCCNXP_MAJOR 204
...@@ -131,6 +132,8 @@ struct sccnxp_port { ...@@ -131,6 +132,8 @@ struct sccnxp_port {
struct timer_list timer; struct timer_list timer;
struct sccnxp_pdata pdata; struct sccnxp_pdata pdata;
struct regulator *regulator;
}; };
static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift) static 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,6 +919,16 @@ static int sccnxp_probe(struct platform_device *pdev)
goto err_out; goto err_out;
} }
s->regulator = devm_regulator_get(&pdev->dev, "VCC");
if (!IS_ERR(s->regulator)) {
ret = regulator_enable(s->regulator);
if (ret) {
dev_err(&pdev->dev,
"Failed to enable regulator: %i\n", ret);
return ret;
}
}
membase = devm_ioremap_resource(&pdev->dev, res); membase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(membase)) { if (IS_ERR(membase)) {
ret = PTR_ERR(membase); ret = PTR_ERR(membase);
...@@ -965,10 +978,6 @@ static int sccnxp_probe(struct platform_device *pdev) ...@@ -965,10 +978,6 @@ static int sccnxp_probe(struct platform_device *pdev)
s->imr = 0; s->imr = 0;
sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0); sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0);
/* Board specific configure */
if (s->pdata.init)
s->pdata.init();
if (!s->poll) { if (!s->poll) {
ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL,
sccnxp_ist, sccnxp_ist,
...@@ -1009,8 +1018,8 @@ static int sccnxp_remove(struct platform_device *pdev) ...@@ -1009,8 +1018,8 @@ static int sccnxp_remove(struct platform_device *pdev)
uart_unregister_driver(&s->uart); uart_unregister_driver(&s->uart);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
if (s->pdata.exit) if (!IS_ERR(s->regulator))
s->pdata.exit(); return regulator_disable(s->regulator);
return 0; return 0;
} }
......
...@@ -86,10 +86,6 @@ struct sccnxp_pdata { ...@@ -86,10 +86,6 @@ struct sccnxp_pdata {
const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; const u32 mctrl_cfg[SCCNXP_MAX_UARTS];
/* Timer value for polling mode (usecs) */ /* Timer value for polling mode (usecs) */
const unsigned int poll_time_us; const unsigned int poll_time_us;
/* Called during startup */
void (*init)(void);
/* Called before finish */
void (*exit)(void);
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment