Skip to content

Commit 4b522bb

Browse files
jayxurockchiplinusw
authored andcommitted
pinctrl/rockchip: always enable clock for gpio controller
Since gate and ungate pclk of gpio has very litte benifit for system power consumption, just keep it always ungate. Signed-off-by: Jianqun Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e73f0f0 commit 4b522bb

File tree

1 file changed

+1
-39
lines changed

1 file changed

+1
-39
lines changed

drivers/pinctrl/pinctrl-rockchip.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,17 +2299,8 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
22992299
{
23002300
struct rockchip_pin_bank *bank = gpiochip_get_data(chip);
23012301
u32 data;
2302-
int ret;
23032302

2304-
ret = clk_enable(bank->clk);
2305-
if (ret < 0) {
2306-
dev_err(bank->drvdata->dev,
2307-
"failed to enable clock for bank %s\n", bank->name);
2308-
return ret;
2309-
}
23102303
data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
2311-
clk_disable(bank->clk);
2312-
23132304
if (data & BIT(offset))
23142305
return GPIO_LINE_DIRECTION_OUT;
23152306

@@ -2335,7 +2326,6 @@ static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip,
23352326
if (ret < 0)
23362327
return ret;
23372328

2338-
clk_enable(bank->clk);
23392329
raw_spin_lock_irqsave(&bank->slock, flags);
23402330

23412331
data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
@@ -2347,7 +2337,6 @@ static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip,
23472337
writel_relaxed(data, bank->reg_base + GPIO_SWPORT_DDR);
23482338

23492339
raw_spin_unlock_irqrestore(&bank->slock, flags);
2350-
clk_disable(bank->clk);
23512340

23522341
return 0;
23532342
}
@@ -2798,7 +2787,6 @@ static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
27982787
unsigned long flags;
27992788
u32 data;
28002789

2801-
clk_enable(bank->clk);
28022790
raw_spin_lock_irqsave(&bank->slock, flags);
28032791

28042792
data = readl(reg);
@@ -2808,7 +2796,6 @@ static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
28082796
writel(data, reg);
28092797

28102798
raw_spin_unlock_irqrestore(&bank->slock, flags);
2811-
clk_disable(bank->clk);
28122799
}
28132800

28142801
/*
@@ -2820,9 +2807,7 @@ static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset)
28202807
struct rockchip_pin_bank *bank = gpiochip_get_data(gc);
28212808
u32 data;
28222809

2823-
clk_enable(bank->clk);
28242810
data = readl(bank->reg_base + GPIO_EXT_PORT);
2825-
clk_disable(bank->clk);
28262811
data >>= offset;
28272812
data &= 1;
28282813
return data;
@@ -2858,7 +2843,6 @@ static void rockchip_gpio_set_debounce(struct gpio_chip *gc,
28582843
unsigned long flags;
28592844
u32 data;
28602845

2861-
clk_enable(bank->clk);
28622846
raw_spin_lock_irqsave(&bank->slock, flags);
28632847

28642848
data = readl(reg);
@@ -2869,7 +2853,6 @@ static void rockchip_gpio_set_debounce(struct gpio_chip *gc,
28692853
writel(data, reg);
28702854

28712855
raw_spin_unlock_irqrestore(&bank->slock, flags);
2872-
clk_disable(bank->clk);
28732856
}
28742857

28752858
/*
@@ -2914,9 +2897,7 @@ static int rockchip_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
29142897
if (!bank->domain)
29152898
return -ENXIO;
29162899

2917-
clk_enable(bank->clk);
29182900
virq = irq_create_mapping(bank->domain, offset);
2919-
clk_disable(bank->clk);
29202901

29212902
return (virq) ? : -ENXIO;
29222903
}
@@ -3015,7 +2996,6 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
30152996
if (ret < 0)
30162997
return ret;
30172998

3018-
clk_enable(bank->clk);
30192999
raw_spin_lock_irqsave(&bank->slock, flags);
30203000

30213001
data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR);
@@ -3073,7 +3053,6 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
30733053
default:
30743054
irq_gc_unlock(gc);
30753055
raw_spin_unlock_irqrestore(&bank->slock, flags);
3076-
clk_disable(bank->clk);
30773056
return -EINVAL;
30783057
}
30793058

@@ -3082,7 +3061,6 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
30823061

30833062
irq_gc_unlock(gc);
30843063
raw_spin_unlock_irqrestore(&bank->slock, flags);
3085-
clk_disable(bank->clk);
30863064

30873065
return 0;
30883066
}
@@ -3092,28 +3070,23 @@ static void rockchip_irq_suspend(struct irq_data *d)
30923070
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
30933071
struct rockchip_pin_bank *bank = gc->private;
30943072

3095-
clk_enable(bank->clk);
30963073
bank->saved_masks = irq_reg_readl(gc, GPIO_INTMASK);
30973074
irq_reg_writel(gc, ~gc->wake_active, GPIO_INTMASK);
3098-
clk_disable(bank->clk);
30993075
}
31003076

31013077
static void rockchip_irq_resume(struct irq_data *d)
31023078
{
31033079
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
31043080
struct rockchip_pin_bank *bank = gc->private;
31053081

3106-
clk_enable(bank->clk);
31073082
irq_reg_writel(gc, bank->saved_masks, GPIO_INTMASK);
3108-
clk_disable(bank->clk);
31093083
}
31103084

31113085
static void rockchip_irq_enable(struct irq_data *d)
31123086
{
31133087
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
31143088
struct rockchip_pin_bank *bank = gc->private;
31153089

3116-
clk_enable(bank->clk);
31173090
irq_gc_mask_clr_bit(d);
31183091
}
31193092

@@ -3123,7 +3096,6 @@ static void rockchip_irq_disable(struct irq_data *d)
31233096
struct rockchip_pin_bank *bank = gc->private;
31243097

31253098
irq_gc_mask_set_bit(d);
3126-
clk_disable(bank->clk);
31273099
}
31283100

31293101
static int rockchip_interrupts_register(struct platform_device *pdev,
@@ -3143,19 +3115,11 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
31433115
continue;
31443116
}
31453117

3146-
ret = clk_enable(bank->clk);
3147-
if (ret) {
3148-
dev_err(&pdev->dev, "failed to enable clock for bank %s\n",
3149-
bank->name);
3150-
continue;
3151-
}
3152-
31533118
bank->domain = irq_domain_add_linear(bank->of_node, 32,
31543119
&irq_generic_chip_ops, NULL);
31553120
if (!bank->domain) {
31563121
dev_warn(&pdev->dev, "could not initialize irq domain for bank %s\n",
31573122
bank->name);
3158-
clk_disable(bank->clk);
31593123
continue;
31603124
}
31613125

@@ -3166,7 +3130,6 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
31663130
dev_err(&pdev->dev, "could not alloc generic chips for bank %s\n",
31673131
bank->name);
31683132
irq_domain_remove(bank->domain);
3169-
clk_disable(bank->clk);
31703133
continue;
31713134
}
31723135

@@ -3198,7 +3161,6 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
31983161

31993162
irq_set_chained_handler_and_data(bank->irq,
32003163
rockchip_irq_demux, bank);
3201-
clk_disable(bank->clk);
32023164
}
32033165

32043166
return 0;
@@ -3317,7 +3279,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
33173279
if (IS_ERR(bank->clk))
33183280
return PTR_ERR(bank->clk);
33193281

3320-
return clk_prepare(bank->clk);
3282+
return clk_prepare_enable(bank->clk);
33213283
}
33223284

33233285
static const struct of_device_id rockchip_pinctrl_dt_match[];

0 commit comments

Comments
 (0)