Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 372534
b: refs/heads/master
c: 934cb02
h: refs/heads/master
v: v3
  • Loading branch information
Laurent Pinchart committed Mar 15, 2013
1 parent d7400b4 commit 271f8e2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0b73ee5d534cc6dcb96efb9eac4cf96b40910911
refs/heads/master: 934cb02bab9003bf65afe73e9146a1ea63b26c40
7 changes: 6 additions & 1 deletion trunk/drivers/pinctrl/sh-pfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
return (void __iomem *)address;
}

struct sh_pfc_pin *sh_pfc_get_pin(struct sh_pfc *pfc, unsigned int pin)
{
return &pfc->info->pins[pin];
}

static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
{
if (enum_id < r->begin)
Expand Down Expand Up @@ -278,7 +283,7 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc)
void sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
struct pinmux_data_reg **drp, int *bitp)
{
struct sh_pfc_pin *gpiop = &pfc->info->pins[gpio];
struct sh_pfc_pin *gpiop = sh_pfc_get_pin(pfc, gpio);
int k, n;

k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/pinctrl/sh-pfc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
unsigned long value);
void sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
struct pinmux_data_reg **drp, int *bitp);
struct sh_pfc_pin *sh_pfc_get_pin(struct sh_pfc *pfc, unsigned int pin);
int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type,
int cfg_mode);

Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/pinctrl/sh-pfc/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ static struct sh_pfc *gpio_to_pfc(struct gpio_chip *gc)
static int gpio_pin_request(struct gpio_chip *gc, unsigned offset)
{
struct sh_pfc *pfc = gpio_to_pfc(gc);
struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, offset);

if (pfc->info->pins[offset].enum_id == 0)
if (pin->enum_id == 0)
return -EINVAL;

return pinctrl_request_gpio(offset);
Expand Down
23 changes: 13 additions & 10 deletions trunk/drivers/pinctrl/sh-pfc/pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ static void sh_pfc_noop_disable(struct pinctrl_dev *pctldev, unsigned func,
static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset,
int new_type)
{
unsigned int mark = pfc->info->pins[offset].enum_id;
struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, offset);
unsigned int mark = pin->enum_id;
unsigned long flags;
int pinmux_type;
int ret = -EINVAL;

spin_lock_irqsave(&pfc->lock, flags);

pinmux_type = pfc->info->pins[offset].flags & PINMUX_FLAG_TYPE;
pinmux_type = pin->flags & PINMUX_FLAG_TYPE;

/*
* See if the present config needs to first be de-configured.
Expand Down Expand Up @@ -156,8 +157,8 @@ static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset,
if (sh_pfc_config_mux(pfc, mark, new_type, GPIO_CFG_REQ) != 0)
goto err;

pfc->info->pins[offset].flags &= ~PINMUX_FLAG_TYPE;
pfc->info->pins[offset].flags |= new_type;
pin->flags &= ~PINMUX_FLAG_TYPE;
pin->flags |= new_type;

ret = 0;

Expand All @@ -173,12 +174,13 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev,
{
struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
struct sh_pfc *pfc = pmx->pfc;
struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, offset);
unsigned long flags;
int ret, pinmux_type;

spin_lock_irqsave(&pfc->lock, flags);

pinmux_type = pfc->info->pins[offset].flags & PINMUX_FLAG_TYPE;
pinmux_type = pin->flags & PINMUX_FLAG_TYPE;

switch (pinmux_type) {
case PINMUX_TYPE_GPIO:
Expand Down Expand Up @@ -206,15 +208,15 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev,
{
struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
struct sh_pfc *pfc = pmx->pfc;
struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, offset);
unsigned long flags;
int pinmux_type;

spin_lock_irqsave(&pfc->lock, flags);

pinmux_type = pfc->info->pins[offset].flags & PINMUX_FLAG_TYPE;
pinmux_type = pin->flags & PINMUX_FLAG_TYPE;

sh_pfc_config_mux(pfc, pfc->info->pins[offset].enum_id, pinmux_type,
GPIO_CFG_FREE);
sh_pfc_config_mux(pfc, pin->enum_id, pinmux_type, GPIO_CFG_FREE);

spin_unlock_irqrestore(&pfc->lock, flags);
}
Expand All @@ -240,13 +242,14 @@ static const struct pinmux_ops sh_pfc_pinmux_ops = {
.gpio_set_direction = sh_pfc_gpio_set_direction,
};

static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
unsigned long *config)
{
struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
struct sh_pfc *pfc = pmx->pfc;
struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, _pin);

*config = pfc->info->pins[pin].flags & PINMUX_FLAG_TYPE;
*config = pin->flags & PINMUX_FLAG_TYPE;

return 0;
}
Expand Down

0 comments on commit 271f8e2

Please sign in to comment.