Skip to content

Commit 2808801

Browse files
Anson-Huanglinusw
authored andcommitted
gpio: mxc: add clock operation
Some i.MX SoCs have GPIO clock gates in CCM CCGR, such as i.MX6SLL, need to enable clocks before accessing GPIO registers, add optional clock operation for GPIO driver. Signed-off-by: Anson Huang <[email protected]> Reviewed-by: Fabio Estevam <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 3027743 commit 2808801

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/gpio/gpio-mxc.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2121
*/
2222

23+
#include <linux/clk.h>
2324
#include <linux/err.h>
2425
#include <linux/init.h>
2526
#include <linux/interrupt.h>
@@ -60,6 +61,7 @@ struct mxc_gpio_hwdata {
6061
struct mxc_gpio_port {
6162
struct list_head node;
6263
void __iomem *base;
64+
struct clk *clk;
6365
int irq;
6466
int irq_high;
6567
struct irq_domain *domain;
@@ -434,6 +436,17 @@ static int mxc_gpio_probe(struct platform_device *pdev)
434436
if (port->irq < 0)
435437
return port->irq;
436438

439+
/* the controller clock is optional */
440+
port->clk = devm_clk_get(&pdev->dev, NULL);
441+
if (IS_ERR(port->clk))
442+
port->clk = NULL;
443+
444+
err = clk_prepare_enable(port->clk);
445+
if (err) {
446+
dev_err(&pdev->dev, "Unable to enable clock.\n");
447+
return err;
448+
}
449+
437450
/* disable the interrupt and clear the status */
438451
writel(0, port->base + GPIO_IMR);
439452
writel(~0, port->base + GPIO_ISR);
@@ -502,6 +515,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
502515
out_irqdomain_remove:
503516
irq_domain_remove(port->domain);
504517
out_bgio:
518+
clk_disable_unprepare(port->clk);
505519
dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
506520
return err;
507521
}

0 commit comments

Comments
 (0)