misc: aspeed-lpc: Request and enable LPC clock
The LPC device needs to ensure it's clock is enabled before it can do anything. In the past the clock was enabled and left running by u-boot, however Linux now has an upstream clock driver that disables unused clocks. Tested-by: Lei YU <mine260309@gmail.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
eb105eace9
commit
99aad9e3a9
|
@ -7,6 +7,7 @@
|
||||||
* 2 of the License, or (at your option) any later version.
|
* 2 of the License, or (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/clk.h>
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
#include <linux/miscdevice.h>
|
#include <linux/miscdevice.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
struct aspeed_lpc_ctrl {
|
struct aspeed_lpc_ctrl {
|
||||||
struct miscdevice miscdev;
|
struct miscdevice miscdev;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
struct clk *clk;
|
||||||
phys_addr_t mem_base;
|
phys_addr_t mem_base;
|
||||||
resource_size_t mem_size;
|
resource_size_t mem_size;
|
||||||
u32 pnor_size;
|
u32 pnor_size;
|
||||||
|
@ -221,16 +223,33 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lpc_ctrl->clk = devm_clk_get(dev, NULL);
|
||||||
|
if (IS_ERR(lpc_ctrl->clk)) {
|
||||||
|
dev_err(dev, "couldn't get clock\n");
|
||||||
|
return PTR_ERR(lpc_ctrl->clk);
|
||||||
|
}
|
||||||
|
rc = clk_prepare_enable(lpc_ctrl->clk);
|
||||||
|
if (rc) {
|
||||||
|
dev_err(dev, "couldn't enable clock\n");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR;
|
lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR;
|
||||||
lpc_ctrl->miscdev.name = DEVICE_NAME;
|
lpc_ctrl->miscdev.name = DEVICE_NAME;
|
||||||
lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops;
|
lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops;
|
||||||
lpc_ctrl->miscdev.parent = dev;
|
lpc_ctrl->miscdev.parent = dev;
|
||||||
rc = misc_register(&lpc_ctrl->miscdev);
|
rc = misc_register(&lpc_ctrl->miscdev);
|
||||||
if (rc)
|
if (rc) {
|
||||||
dev_err(dev, "Unable to register device\n");
|
dev_err(dev, "Unable to register device\n");
|
||||||
else
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
dev_info(dev, "Loaded at %pr\n", &resm);
|
dev_info(dev, "Loaded at %pr\n", &resm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err:
|
||||||
|
clk_disable_unprepare(lpc_ctrl->clk);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +258,7 @@ static int aspeed_lpc_ctrl_remove(struct platform_device *pdev)
|
||||||
struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev);
|
struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
misc_deregister(&lpc_ctrl->miscdev);
|
misc_deregister(&lpc_ctrl->miscdev);
|
||||||
|
clk_disable_unprepare(lpc_ctrl->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue