Commit 4aeacd5b authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Simon Horman

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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
parent 90efde22
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "core.h" #include "core.h"
static int pfc_ioremap(struct sh_pfc *pfc) static int sh_pfc_ioremap(struct sh_pfc *pfc)
{ {
struct resource *res; struct resource *res;
int k; int k;
...@@ -53,10 +53,10 @@ static int pfc_ioremap(struct sh_pfc *pfc) ...@@ -53,10 +53,10 @@ static int pfc_ioremap(struct sh_pfc *pfc)
return 0; return 0;
} }
static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc, static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
unsigned long address) unsigned long address)
{ {
struct pfc_window *window; struct sh_pfc_window *window;
int k; int k;
/* scan through physical windows and convert address */ /* scan through physical windows and convert address */
...@@ -76,7 +76,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc, ...@@ -76,7 +76,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
return (void __iomem *)address; return (void __iomem *)address;
} }
static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
{ {
if (enum_id < r->begin) if (enum_id < r->begin)
return 0; return 0;
...@@ -87,8 +87,8 @@ static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) ...@@ -87,8 +87,8 @@ static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
return 1; return 1;
} }
static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg, static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
unsigned long reg_width) unsigned long reg_width)
{ {
switch (reg_width) { switch (reg_width) {
case 8: case 8:
...@@ -103,9 +103,8 @@ static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg, ...@@ -103,9 +103,8 @@ static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg,
return 0; return 0;
} }
static void gpio_write_raw_reg(void __iomem *mapped_reg, static void sh_pfc_write_raw_reg(void __iomem *mapped_reg,
unsigned long reg_width, unsigned long reg_width, unsigned long data)
unsigned long data)
{ {
switch (reg_width) { switch (reg_width) {
case 8: case 8:
...@@ -131,7 +130,7 @@ int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos) ...@@ -131,7 +130,7 @@ int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos)
pr_debug("read_bit: addr = %lx, pos = %ld, " pr_debug("read_bit: addr = %lx, pos = %ld, "
"r_width = %ld\n", dr->reg, pos, dr->reg_width); "r_width = %ld\n", dr->reg, pos, dr->reg_width);
return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1; return (sh_pfc_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
} }
void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, 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,19 +149,19 @@ void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
else else
clear_bit(pos, &dr->reg_shadow); clear_bit(pos, &dr->reg_shadow);
gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow); sh_pfc_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
} }
static void config_reg_helper(struct sh_pfc *pfc, static void sh_pfc_config_reg_helper(struct sh_pfc *pfc,
struct pinmux_cfg_reg *crp, struct pinmux_cfg_reg *crp,
unsigned long in_pos, unsigned long in_pos,
void __iomem **mapped_regp, void __iomem **mapped_regp,
unsigned long *maskp, unsigned long *maskp,
unsigned long *posp) unsigned long *posp)
{ {
int k; int k;
*mapped_regp = pfc_phys_to_virt(pfc, crp->reg); *mapped_regp = sh_pfc_phys_to_virt(pfc, crp->reg);
if (crp->field_width) { if (crp->field_width) {
*maskp = (1 << crp->field_width) - 1; *maskp = (1 << crp->field_width) - 1;
...@@ -175,30 +174,30 @@ static void config_reg_helper(struct sh_pfc *pfc, ...@@ -175,30 +174,30 @@ static void config_reg_helper(struct sh_pfc *pfc,
} }
} }
static int read_config_reg(struct sh_pfc *pfc, static int sh_pfc_read_config_reg(struct sh_pfc *pfc,
struct pinmux_cfg_reg *crp, struct pinmux_cfg_reg *crp,
unsigned long field) unsigned long field)
{ {
void __iomem *mapped_reg; void __iomem *mapped_reg;
unsigned long mask, pos; unsigned long mask, pos;
config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
pr_debug("read_reg: addr = %lx, field = %ld, " pr_debug("read_reg: addr = %lx, field = %ld, "
"r_width = %ld, f_width = %ld\n", "r_width = %ld, f_width = %ld\n",
crp->reg, field, crp->reg_width, crp->field_width); crp->reg, field, crp->reg_width, crp->field_width);
return (gpio_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask; return (sh_pfc_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask;
} }
static void write_config_reg(struct sh_pfc *pfc, static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
struct pinmux_cfg_reg *crp, struct pinmux_cfg_reg *crp,
unsigned long field, unsigned long value) unsigned long field, unsigned long value)
{ {
void __iomem *mapped_reg; void __iomem *mapped_reg;
unsigned long mask, pos, data; unsigned long mask, pos, data;
config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
pr_debug("write_reg addr = %lx, value = %ld, field = %ld, " pr_debug("write_reg addr = %lx, value = %ld, field = %ld, "
"r_width = %ld, f_width = %ld\n", "r_width = %ld, f_width = %ld\n",
...@@ -207,24 +206,25 @@ static void write_config_reg(struct sh_pfc *pfc, ...@@ -207,24 +206,25 @@ static void write_config_reg(struct sh_pfc *pfc,
mask = ~(mask << pos); mask = ~(mask << pos);
value = value << pos; value = value << pos;
data = gpio_read_raw_reg(mapped_reg, crp->reg_width); data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width);
data &= mask; data &= mask;
data |= value; data |= value;
if (pfc->pdata->unlock_reg) if (pfc->pdata->unlock_reg)
gpio_write_raw_reg(pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), sh_pfc_write_raw_reg(
32, ~data); sh_pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), 32,
~data);
gpio_write_raw_reg(mapped_reg, crp->reg_width, data); sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data);
} }
static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio) static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
{ {
struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio];
struct pinmux_data_reg *data_reg; struct pinmux_data_reg *data_reg;
int k, n; int k, n;
if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data)) if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data))
return -1; return -1;
k = 0; k = 0;
...@@ -234,7 +234,7 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio) ...@@ -234,7 +234,7 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
if (!data_reg->reg_width) if (!data_reg->reg_width)
break; break;
data_reg->mapped_reg = pfc_phys_to_virt(pfc, data_reg->reg); data_reg->mapped_reg = sh_pfc_phys_to_virt(pfc, data_reg->reg);
for (n = 0; n < data_reg->reg_width; n++) { for (n = 0; n < data_reg->reg_width; n++) {
if (data_reg->enum_ids[n] == gpiop->enum_id) { 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,13 +253,13 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
return -1; return -1;
} }
static void setup_data_regs(struct sh_pfc *pfc) static void sh_pfc_setup_data_regs(struct sh_pfc *pfc)
{ {
struct pinmux_data_reg *drp; struct pinmux_data_reg *drp;
int k; int k;
for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++) for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++)
setup_data_reg(pfc, k); sh_pfc_setup_data_reg(pfc, k);
k = 0; k = 0;
while (1) { while (1) {
...@@ -268,8 +268,8 @@ static void setup_data_regs(struct sh_pfc *pfc) ...@@ -268,8 +268,8 @@ static void setup_data_regs(struct sh_pfc *pfc)
if (!drp->reg_width) if (!drp->reg_width)
break; break;
drp->reg_shadow = gpio_read_raw_reg(drp->mapped_reg, drp->reg_shadow = sh_pfc_read_raw_reg(drp->mapped_reg,
drp->reg_width); drp->reg_width);
k++; k++;
} }
} }
...@@ -280,7 +280,7 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, ...@@ -280,7 +280,7 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio];
int k, n; int k, n;
if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data)) if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data))
return -1; return -1;
k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; 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,10 +290,9 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
return 0; return 0;
} }
static int get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
struct pinmux_cfg_reg **crp, struct pinmux_cfg_reg **crp, int *fieldp,
int *fieldp, int *valuep, int *valuep, unsigned long **cntp)
unsigned long **cntp)
{ {
struct pinmux_cfg_reg *config_reg; struct pinmux_cfg_reg *config_reg;
unsigned long r_width, f_width, curr_width, ncomb; 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,8 +342,8 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
pinmux_enum_t *data = pfc->pdata->gpio_data; pinmux_enum_t *data = pfc->pdata->gpio_data;
int k; int k;
if (!enum_in_range(enum_id, &pfc->pdata->data)) { if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->data)) {
if (!enum_in_range(enum_id, &pfc->pdata->mark)) { if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->mark)) {
pr_err("non data/mark enum_id for gpio %d\n", gpio); pr_err("non data/mark enum_id for gpio %d\n", gpio);
return -1; return -1;
} }
...@@ -414,7 +413,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, ...@@ -414,7 +413,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
break; break;
/* first check if this is a function enum */ /* first check if this is a function enum */
in_range = enum_in_range(enum_id, &pfc->pdata->function); in_range = sh_pfc_enum_in_range(enum_id, &pfc->pdata->function);
if (!in_range) { if (!in_range) {
/* not a function enum */ /* not a function enum */
if (range) { if (range) {
...@@ -426,7 +425,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, ...@@ -426,7 +425,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
* for this case we only allow function enums * for this case we only allow function enums
* and the enums that match the other range. * and the enums that match the other range.
*/ */
in_range = enum_in_range(enum_id, range); in_range = sh_pfc_enum_in_range(enum_id, range);
/* /*
* special case pass through for fixed * 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,19 +450,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
if (!in_range) if (!in_range)
continue; continue;
if (get_config_reg(pfc, enum_id, &cr, if (sh_pfc_get_config_reg(pfc, enum_id, &cr,
&field, &value, &cntp) != 0) &field, &value, &cntp) != 0)
goto out_err; goto out_err;
switch (cfg_mode) { switch (cfg_mode) {
case GPIO_CFG_DRYRUN: case GPIO_CFG_DRYRUN:
if (!*cntp || if (!*cntp ||
(read_config_reg(pfc, cr, field) != value)) (sh_pfc_read_config_reg(pfc, cr, field) != value))
continue; continue;
break; break;
case GPIO_CFG_REQ: case GPIO_CFG_REQ:
write_config_reg(pfc, cr, field, value); sh_pfc_write_config_reg(pfc, cr, field, value);
*cntp = *cntp + 1; *cntp = *cntp + 1;
break; break;
...@@ -499,14 +498,14 @@ static int sh_pfc_probe(struct platform_device *pdev) ...@@ -499,14 +498,14 @@ static int sh_pfc_probe(struct platform_device *pdev)
pfc->pdata = pdata; pfc->pdata = pdata;
pfc->dev = &pdev->dev; pfc->dev = &pdev->dev;
ret = pfc_ioremap(pfc); ret = sh_pfc_ioremap(pfc);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
return ret; return ret;
spin_lock_init(&pfc->lock); spin_lock_init(&pfc->lock);
pinctrl_provide_dummies(); pinctrl_provide_dummies();
setup_data_regs(pfc); sh_pfc_setup_data_regs(pfc);
/* /*
* Initialize pinctrl bindings first * Initialize pinctrl bindings first
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/sh_pfc.h> #include <linux/sh_pfc.h>
#include <linux/types.h> #include <linux/types.h>
struct pfc_window { struct sh_pfc_window {
phys_addr_t phys; phys_addr_t phys;
void __iomem *virt; void __iomem *virt;
unsigned long size; unsigned long size;
...@@ -28,7 +28,7 @@ struct sh_pfc { ...@@ -28,7 +28,7 @@ struct sh_pfc {
struct sh_pfc_platform_data *pdata; struct sh_pfc_platform_data *pdata;
spinlock_t lock; spinlock_t lock;
struct pfc_window *window; struct sh_pfc_window *window;
struct sh_pfc_chip *gpio; struct sh_pfc_chip *gpio;
struct sh_pfc_pinctrl *pinctrl; struct sh_pfc_pinctrl *pinctrl;
}; };
......
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