Skip to content

Commit

Permalink
sh-pfc: Add support for SoC-specific initialization
Browse files Browse the repository at this point in the history
Add two optional init and exit SoC operations and call them from the
core at probe and remove time.

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>
  • Loading branch information
Laurent Pinchart authored and Simon Horman committed Jun 5, 2013
1 parent 0ccaf5b commit 0c15106
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion drivers/pinctrl/sh-pfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,20 @@ static int sh_pfc_probe(struct platform_device *pdev)

spin_lock_init(&pfc->lock);

if (info->ops && info->ops->init) {
ret = info->ops->init(pfc);
if (ret < 0)
return ret;
}

pinctrl_provide_dummies();

/*
* Initialize pinctrl bindings first
*/
ret = sh_pfc_register_pinctrl(pfc);
if (unlikely(ret != 0))
return ret;
goto error;

#ifdef CONFIG_GPIO_SH_PFC
/*
Expand All @@ -401,6 +407,11 @@ static int sh_pfc_probe(struct platform_device *pdev)
dev_info(pfc->dev, "%s support registered\n", info->name);

return 0;

error:
if (info->ops && info->ops->exit)
info->ops->exit(pfc);
return ret;
}

static int sh_pfc_remove(struct platform_device *pdev)
Expand All @@ -412,6 +423,9 @@ static int sh_pfc_remove(struct platform_device *pdev)
#endif
sh_pfc_unregister_pinctrl(pfc);

if (pfc->info->ops && pfc->info->ops->exit)
pfc->info->ops->exit(pfc);

platform_set_drvdata(pdev, NULL);

return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/pinctrl/sh-pfc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct sh_pfc_pinctrl;
struct sh_pfc {
struct device *dev;
const struct sh_pfc_soc_info *info;
void *soc_data;
spinlock_t lock;

unsigned int num_windows;
Expand Down
2 changes: 2 additions & 0 deletions drivers/pinctrl/sh-pfc/sh_pfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ struct pinmux_range {
struct sh_pfc;

struct sh_pfc_soc_operations {
int (*init)(struct sh_pfc *pfc);
void (*exit)(struct sh_pfc *pfc);
unsigned int (*get_bias)(struct sh_pfc *pfc, unsigned int pin);
void (*set_bias)(struct sh_pfc *pfc, unsigned int pin,
unsigned int bias);
Expand Down

0 comments on commit 0c15106

Please sign in to comment.