diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2012-12-15 17:50:53 -0500 |
|---|---|---|
| committer | Simon Horman <horms+renesas@verge.net.au> | 2013-01-24 19:24:22 -0500 |
| commit | 4aeacd5bd5c354c1b36bfe3d5d72806ecd9605a0 (patch) | |
| tree | 4ee828ad1f6027bbc3a9ed6c0b83da5807be21dd /drivers/sh | |
| parent | 90efde223d2ab5ab84008986d97df0f01a49f15f (diff) | |
sh-pfc: Use sh_pfc_ namespace prefix through the whole driver
Most of the function and structure names are prefixed by sh_pfc_. Fix
the ones that are not to avoid namespace clashes (especially for
functions that start with gpio_).
Not included in this patch are the platform data structures, those will
be reworked later.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/sh')
| -rw-r--r-- | drivers/sh/pfc/core.c | 107 | ||||
| -rw-r--r-- | drivers/sh/pfc/core.h | 4 |
2 files changed, 55 insertions, 56 deletions
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c index ccf4b7a7cefa..1bb38e8b36ad 100644 --- a/drivers/sh/pfc/core.c +++ b/drivers/sh/pfc/core.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #include "core.h" | 27 | #include "core.h" |
| 28 | 28 | ||
| 29 | static int pfc_ioremap(struct sh_pfc *pfc) | 29 | static int sh_pfc_ioremap(struct sh_pfc *pfc) |
| 30 | { | 30 | { |
| 31 | struct resource *res; | 31 | struct resource *res; |
| 32 | int k; | 32 | int k; |
| @@ -53,10 +53,10 @@ static int pfc_ioremap(struct sh_pfc *pfc) | |||
| 53 | return 0; | 53 | return 0; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc, | 56 | static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc, |
| 57 | unsigned long address) | 57 | unsigned long address) |
| 58 | { | 58 | { |
| 59 | struct pfc_window *window; | 59 | struct sh_pfc_window *window; |
| 60 | int k; | 60 | int k; |
| 61 | 61 | ||
| 62 | /* scan through physical windows and convert address */ | 62 | /* scan through physical windows and convert address */ |
| @@ -76,7 +76,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc, | |||
| 76 | return (void __iomem *)address; | 76 | return (void __iomem *)address; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) | 79 | static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) |
| 80 | { | 80 | { |
| 81 | if (enum_id < r->begin) | 81 | if (enum_id < r->begin) |
| 82 | return 0; | 82 | return 0; |
| @@ -87,8 +87,8 @@ static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) | |||
| 87 | return 1; | 87 | return 1; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg, | 90 | static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg, |
| 91 | unsigned long reg_width) | 91 | unsigned long reg_width) |
| 92 | { | 92 | { |
| 93 | switch (reg_width) { | 93 | switch (reg_width) { |
| 94 | case 8: | 94 | case 8: |
| @@ -103,9 +103,8 @@ static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg, | |||
| 103 | return 0; | 103 | return 0; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | static void gpio_write_raw_reg(void __iomem *mapped_reg, | 106 | static void sh_pfc_write_raw_reg(void __iomem *mapped_reg, |
| 107 | unsigned long reg_width, | 107 | unsigned long reg_width, unsigned long data) |
| 108 | unsigned long data) | ||
| 109 | { | 108 | { |
| 110 | switch (reg_width) { | 109 | switch (reg_width) { |
| 111 | case 8: | 110 | case 8: |
| @@ -131,7 +130,7 @@ int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos) | |||
| 131 | pr_debug("read_bit: addr = %lx, pos = %ld, " | 130 | pr_debug("read_bit: addr = %lx, pos = %ld, " |
| 132 | "r_width = %ld\n", dr->reg, pos, dr->reg_width); | 131 | "r_width = %ld\n", dr->reg, pos, dr->reg_width); |
| 133 | 132 | ||
| 134 | return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1; | 133 | return (sh_pfc_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1; |
| 135 | } | 134 | } |
| 136 | 135 | ||
| 137 | void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, | 136 | void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, |
| @@ -150,19 +149,19 @@ void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, | |||
| 150 | else | 149 | else |
| 151 | clear_bit(pos, &dr->reg_shadow); | 150 | clear_bit(pos, &dr->reg_shadow); |
| 152 | 151 | ||
| 153 | gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow); | 152 | sh_pfc_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow); |
| 154 | } | 153 | } |
| 155 | 154 | ||
| 156 | static void config_reg_helper(struct sh_pfc *pfc, | 155 | static void sh_pfc_config_reg_helper(struct sh_pfc *pfc, |
| 157 | struct pinmux_cfg_reg *crp, | 156 | struct pinmux_cfg_reg *crp, |
| 158 | unsigned long in_pos, | 157 | unsigned long in_pos, |
| 159 | void __iomem **mapped_regp, | 158 | void __iomem **mapped_regp, |
| 160 | unsigned long *maskp, | 159 | unsigned long *maskp, |
| 161 | unsigned long *posp) | 160 | unsigned long *posp) |
| 162 | { | 161 | { |
| 163 | int k; | 162 | int k; |
| 164 | 163 | ||
| 165 | *mapped_regp = pfc_phys_to_virt(pfc, crp->reg); | 164 | *mapped_regp = sh_pfc_phys_to_virt(pfc, crp->reg); |
| 166 | 165 | ||
| 167 | if (crp->field_width) { | 166 | if (crp->field_width) { |
| 168 | *maskp = (1 << crp->field_width) - 1; | 167 | *maskp = (1 << crp->field_width) - 1; |
| @@ -175,30 +174,30 @@ static void config_reg_helper(struct sh_pfc *pfc, | |||
| 175 | } | 174 | } |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | static int read_config_reg(struct sh_pfc *pfc, | 177 | static int sh_pfc_read_config_reg(struct sh_pfc *pfc, |
| 179 | struct pinmux_cfg_reg *crp, | 178 | struct pinmux_cfg_reg *crp, |
| 180 | unsigned long field) | 179 | unsigned long field) |
| 181 | { | 180 | { |
| 182 | void __iomem *mapped_reg; | 181 | void __iomem *mapped_reg; |
| 183 | unsigned long mask, pos; | 182 | unsigned long mask, pos; |
| 184 | 183 | ||
| 185 | config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); | 184 | sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); |
| 186 | 185 | ||
| 187 | pr_debug("read_reg: addr = %lx, field = %ld, " | 186 | pr_debug("read_reg: addr = %lx, field = %ld, " |
| 188 | "r_width = %ld, f_width = %ld\n", | 187 | "r_width = %ld, f_width = %ld\n", |
| 189 | crp->reg, field, crp->reg_width, crp->field_width); | 188 | crp->reg, field, crp->reg_width, crp->field_width); |
| 190 | 189 | ||
| 191 | return (gpio_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask; | 190 | return (sh_pfc_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask; |
| 192 | } | 191 | } |
| 193 | 192 | ||
| 194 | static void write_config_reg(struct sh_pfc *pfc, | 193 | static void sh_pfc_write_config_reg(struct sh_pfc *pfc, |
| 195 | struct pinmux_cfg_reg *crp, | 194 | struct pinmux_cfg_reg *crp, |
| 196 | unsigned long field, unsigned long value) | 195 | unsigned long field, unsigned long value) |
| 197 | { | 196 | { |
| 198 | void __iomem *mapped_reg; | 197 | void __iomem *mapped_reg; |
| 199 | unsigned long mask, pos, data; | 198 | unsigned long mask, pos, data; |
| 200 | 199 | ||
| 201 | config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); | 200 | sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); |
| 202 | 201 | ||
| 203 | pr_debug("write_reg addr = %lx, value = %ld, field = %ld, " | 202 | pr_debug("write_reg addr = %lx, value = %ld, field = %ld, " |
| 204 | "r_width = %ld, f_width = %ld\n", | 203 | "r_width = %ld, f_width = %ld\n", |
| @@ -207,24 +206,25 @@ static void write_config_reg(struct sh_pfc *pfc, | |||
| 207 | mask = ~(mask << pos); | 206 | mask = ~(mask << pos); |
| 208 | value = value << pos; | 207 | value = value << pos; |
| 209 | 208 | ||
| 210 | data = gpio_read_raw_reg(mapped_reg, crp->reg_width); | 209 | data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width); |
| 211 | data &= mask; | 210 | data &= mask; |
| 212 | data |= value; | 211 | data |= value; |
| 213 | 212 | ||
| 214 | if (pfc->pdata->unlock_reg) | 213 | if (pfc->pdata->unlock_reg) |
| 215 | gpio_write_raw_reg(pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), | 214 | sh_pfc_write_raw_reg( |
| 216 | 32, ~data); | 215 | sh_pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), 32, |
| 216 | ~data); | ||
| 217 | 217 | ||
| 218 | gpio_write_raw_reg(mapped_reg, crp->reg_width, data); | 218 | sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio) | 221 | static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio) |
| 222 | { | 222 | { |
| 223 | struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; | 223 | struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; |
| 224 | struct pinmux_data_reg *data_reg; | 224 | struct pinmux_data_reg *data_reg; |
| 225 | int k, n; | 225 | int k, n; |
| 226 | 226 | ||
| 227 | if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data)) | 227 | if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) |
| 228 | return -1; | 228 | return -1; |
| 229 | 229 | ||
| 230 | k = 0; | 230 | k = 0; |
| @@ -234,7 +234,7 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio) | |||
| 234 | if (!data_reg->reg_width) | 234 | if (!data_reg->reg_width) |
| 235 | break; | 235 | break; |
| 236 | 236 | ||
| 237 | data_reg->mapped_reg = pfc_phys_to_virt(pfc, data_reg->reg); | 237 | data_reg->mapped_reg = sh_pfc_phys_to_virt(pfc, data_reg->reg); |
| 238 | 238 | ||
| 239 | for (n = 0; n < data_reg->reg_width; n++) { | 239 | for (n = 0; n < data_reg->reg_width; n++) { |
| 240 | if (data_reg->enum_ids[n] == gpiop->enum_id) { | 240 | if (data_reg->enum_ids[n] == gpiop->enum_id) { |
| @@ -253,13 +253,13 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio) | |||
| 253 | return -1; | 253 | return -1; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | static void setup_data_regs(struct sh_pfc *pfc) | 256 | static void sh_pfc_setup_data_regs(struct sh_pfc *pfc) |
| 257 | { | 257 | { |
| 258 | struct pinmux_data_reg *drp; | 258 | struct pinmux_data_reg *drp; |
| 259 | int k; | 259 | int k; |
| 260 | 260 | ||
| 261 | for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++) | 261 | for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++) |
| 262 | setup_data_reg(pfc, k); | 262 | sh_pfc_setup_data_reg(pfc, k); |
| 263 | 263 | ||
| 264 | k = 0; | 264 | k = 0; |
| 265 | while (1) { | 265 | while (1) { |
| @@ -268,8 +268,8 @@ static void setup_data_regs(struct sh_pfc *pfc) | |||
| 268 | if (!drp->reg_width) | 268 | if (!drp->reg_width) |
| 269 | break; | 269 | break; |
| 270 | 270 | ||
| 271 | drp->reg_shadow = gpio_read_raw_reg(drp->mapped_reg, | 271 | drp->reg_shadow = sh_pfc_read_raw_reg(drp->mapped_reg, |
| 272 | drp->reg_width); | 272 | drp->reg_width); |
| 273 | k++; | 273 | k++; |
| 274 | } | 274 | } |
| 275 | } | 275 | } |
| @@ -280,7 +280,7 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, | |||
| 280 | struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; | 280 | struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; |
| 281 | int k, n; | 281 | int k, n; |
| 282 | 282 | ||
| 283 | if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data)) | 283 | if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) |
| 284 | return -1; | 284 | return -1; |
| 285 | 285 | ||
| 286 | k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; | 286 | k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; |
| @@ -290,10 +290,9 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, | |||
| 290 | return 0; | 290 | return 0; |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | static int get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, | 293 | static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, |
| 294 | struct pinmux_cfg_reg **crp, | 294 | struct pinmux_cfg_reg **crp, int *fieldp, |
| 295 | int *fieldp, int *valuep, | 295 | int *valuep, unsigned long **cntp) |
| 296 | unsigned long **cntp) | ||
| 297 | { | 296 | { |
| 298 | struct pinmux_cfg_reg *config_reg; | 297 | struct pinmux_cfg_reg *config_reg; |
| 299 | unsigned long r_width, f_width, curr_width, ncomb; | 298 | unsigned long r_width, f_width, curr_width, ncomb; |
| @@ -343,8 +342,8 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, | |||
| 343 | pinmux_enum_t *data = pfc->pdata->gpio_data; | 342 | pinmux_enum_t *data = pfc->pdata->gpio_data; |
| 344 | int k; | 343 | int k; |
| 345 | 344 | ||
| 346 | if (!enum_in_range(enum_id, &pfc->pdata->data)) { | 345 | if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->data)) { |
| 347 | if (!enum_in_range(enum_id, &pfc->pdata->mark)) { | 346 | if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->mark)) { |
| 348 | pr_err("non data/mark enum_id for gpio %d\n", gpio); | 347 | pr_err("non data/mark enum_id for gpio %d\n", gpio); |
| 349 | return -1; | 348 | return -1; |
| 350 | } | 349 | } |
| @@ -414,7 +413,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, | |||
| 414 | break; | 413 | break; |
| 415 | 414 | ||
| 416 | /* first check if this is a function enum */ | 415 | /* first check if this is a function enum */ |
| 417 | in_range = enum_in_range(enum_id, &pfc->pdata->function); | 416 | in_range = sh_pfc_enum_in_range(enum_id, &pfc->pdata->function); |
| 418 | if (!in_range) { | 417 | if (!in_range) { |
| 419 | /* not a function enum */ | 418 | /* not a function enum */ |
| 420 | if (range) { | 419 | if (range) { |
| @@ -426,7 +425,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, | |||
| 426 | * for this case we only allow function enums | 425 | * for this case we only allow function enums |
| 427 | * and the enums that match the other range. | 426 | * and the enums that match the other range. |
| 428 | */ | 427 | */ |
| 429 | in_range = enum_in_range(enum_id, range); | 428 | in_range = sh_pfc_enum_in_range(enum_id, range); |
| 430 | 429 | ||
| 431 | /* | 430 | /* |
| 432 | * special case pass through for fixed | 431 | * special case pass through for fixed |
| @@ -451,19 +450,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, | |||
| 451 | if (!in_range) | 450 | if (!in_range) |
| 452 | continue; | 451 | continue; |
| 453 | 452 | ||
| 454 | if (get_config_reg(pfc, enum_id, &cr, | 453 | if (sh_pfc_get_config_reg(pfc, enum_id, &cr, |
| 455 | &field, &value, &cntp) != 0) | 454 | &field, &value, &cntp) != 0) |
| 456 | goto out_err; | 455 | goto out_err; |
| 457 | 456 | ||
| 458 | switch (cfg_mode) { | 457 | switch (cfg_mode) { |
| 459 | case GPIO_CFG_DRYRUN: | 458 | case GPIO_CFG_DRYRUN: |
| 460 | if (!*cntp || | 459 | if (!*cntp || |
| 461 | (read_config_reg(pfc, cr, field) != value)) | 460 | (sh_pfc_read_config_reg(pfc, cr, field) != value)) |
| 462 | continue; | 461 | continue; |
| 463 | break; | 462 | break; |
| 464 | 463 | ||
| 465 | case GPIO_CFG_REQ: | 464 | case GPIO_CFG_REQ: |
| 466 | write_config_reg(pfc, cr, field, value); | 465 | sh_pfc_write_config_reg(pfc, cr, field, value); |
| 467 | *cntp = *cntp + 1; | 466 | *cntp = *cntp + 1; |
| 468 | break; | 467 | break; |
| 469 | 468 | ||
| @@ -499,14 +498,14 @@ static int sh_pfc_probe(struct platform_device *pdev) | |||
| 499 | pfc->pdata = pdata; | 498 | pfc->pdata = pdata; |
| 500 | pfc->dev = &pdev->dev; | 499 | pfc->dev = &pdev->dev; |
| 501 | 500 | ||
| 502 | ret = pfc_ioremap(pfc); | 501 | ret = sh_pfc_ioremap(pfc); |
| 503 | if (unlikely(ret < 0)) | 502 | if (unlikely(ret < 0)) |
| 504 | return ret; | 503 | return ret; |
| 505 | 504 | ||
| 506 | spin_lock_init(&pfc->lock); | 505 | spin_lock_init(&pfc->lock); |
| 507 | 506 | ||
| 508 | pinctrl_provide_dummies(); | 507 | pinctrl_provide_dummies(); |
| 509 | setup_data_regs(pfc); | 508 | sh_pfc_setup_data_regs(pfc); |
| 510 | 509 | ||
| 511 | /* | 510 | /* |
| 512 | * Initialize pinctrl bindings first | 511 | * Initialize pinctrl bindings first |
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h index 1287b3e6222c..d6a40bc592ff 100644 --- a/drivers/sh/pfc/core.h +++ b/drivers/sh/pfc/core.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include <linux/sh_pfc.h> | 14 | #include <linux/sh_pfc.h> |
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | 16 | ||
| 17 | struct pfc_window { | 17 | struct sh_pfc_window { |
| 18 | phys_addr_t phys; | 18 | phys_addr_t phys; |
| 19 | void __iomem *virt; | 19 | void __iomem *virt; |
| 20 | unsigned long size; | 20 | unsigned long size; |
| @@ -28,7 +28,7 @@ struct sh_pfc { | |||
| 28 | struct sh_pfc_platform_data *pdata; | 28 | struct sh_pfc_platform_data *pdata; |
| 29 | spinlock_t lock; | 29 | spinlock_t lock; |
| 30 | 30 | ||
| 31 | struct pfc_window *window; | 31 | struct sh_pfc_window *window; |
| 32 | struct sh_pfc_chip *gpio; | 32 | struct sh_pfc_chip *gpio; |
| 33 | struct sh_pfc_pinctrl *pinctrl; | 33 | struct sh_pfc_pinctrl *pinctrl; |
| 34 | }; | 34 | }; |
