2008-10-08 19:41:43 +08:00
|
|
|
/*
|
2012-06-20 16:29:04 +08:00
|
|
|
* SuperH Pin Function Controller support.
|
2008-10-08 19:41:43 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Magnus Damm
|
2012-06-20 16:29:04 +08:00
|
|
|
* Copyright (C) 2009 - 2012 Paul Mundt
|
2008-10-08 19:41:43 +08:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
2012-12-16 06:50:47 +08:00
|
|
|
|
|
|
|
#define DRV_NAME "sh-pfc"
|
2012-12-16 06:50:45 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
2010-10-04 02:54:56 +08:00
|
|
|
|
2012-12-16 06:50:52 +08:00
|
|
|
#include <linux/bitops.h>
|
2008-10-08 19:41:43 +08:00
|
|
|
#include <linux/err.h>
|
2012-12-16 06:50:52 +08:00
|
|
|
#include <linux/errno.h>
|
2008-10-08 19:41:43 +08:00
|
|
|
#include <linux/io.h>
|
2011-12-09 11:14:27 +08:00
|
|
|
#include <linux/ioport.h>
|
2012-12-16 06:50:52 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2012-07-10 11:08:14 +08:00
|
|
|
#include <linux/pinctrl/machine.h>
|
2012-12-16 06:50:47 +08:00
|
|
|
#include <linux/platform_device.h>
|
2012-12-16 06:50:52 +08:00
|
|
|
#include <linux/slab.h>
|
2011-12-09 11:14:27 +08:00
|
|
|
|
2012-12-16 06:50:44 +08:00
|
|
|
#include "core.h"
|
|
|
|
|
2012-12-16 06:50:55 +08:00
|
|
|
static int sh_pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
|
2011-12-09 11:14:27 +08:00
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
int k;
|
|
|
|
|
2013-02-17 06:39:07 +08:00
|
|
|
if (pdev->num_resources == 0)
|
|
|
|
return -EINVAL;
|
2011-12-09 11:14:27 +08:00
|
|
|
|
2012-12-16 06:51:18 +08:00
|
|
|
pfc->window = devm_kzalloc(pfc->dev, pdev->num_resources *
|
2012-12-16 06:50:48 +08:00
|
|
|
sizeof(*pfc->window), GFP_NOWAIT);
|
2012-06-20 16:29:04 +08:00
|
|
|
if (!pfc->window)
|
2012-12-16 06:50:48 +08:00
|
|
|
return -ENOMEM;
|
2011-12-09 11:14:27 +08:00
|
|
|
|
2012-12-16 06:51:18 +08:00
|
|
|
pfc->num_windows = pdev->num_resources;
|
2012-12-16 06:50:55 +08:00
|
|
|
|
2012-12-16 06:51:18 +08:00
|
|
|
for (k = 0, res = pdev->resource; k < pdev->num_resources; k++, res++) {
|
2011-12-09 11:14:27 +08:00
|
|
|
WARN_ON(resource_type(res) != IORESOURCE_MEM);
|
2012-06-20 16:29:04 +08:00
|
|
|
pfc->window[k].phys = res->start;
|
|
|
|
pfc->window[k].size = resource_size(res);
|
2012-12-16 06:50:49 +08:00
|
|
|
pfc->window[k].virt = devm_ioremap_nocache(pfc->dev, res->start,
|
|
|
|
resource_size(res));
|
|
|
|
if (!pfc->window[k].virt)
|
2012-12-16 06:50:48 +08:00
|
|
|
return -ENOMEM;
|
2011-12-09 11:14:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-17 07:26:33 +08:00
|
|
|
static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
|
|
|
|
unsigned long address)
|
2011-12-09 11:14:27 +08:00
|
|
|
{
|
2012-12-16 06:50:53 +08:00
|
|
|
struct sh_pfc_window *window;
|
2013-02-17 06:39:07 +08:00
|
|
|
unsigned int i;
|
2011-12-09 11:14:27 +08:00
|
|
|
|
|
|
|
/* scan through physical windows and convert address */
|
2013-02-17 06:39:07 +08:00
|
|
|
for (i = 0; i < pfc->num_windows; i++) {
|
|
|
|
window = pfc->window + i;
|
2011-12-09 11:14:27 +08:00
|
|
|
|
|
|
|
if (address < window->phys)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (address >= (window->phys + window->size))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return window->virt + (address - window->phys);
|
|
|
|
}
|
|
|
|
|
2013-02-17 06:39:07 +08:00
|
|
|
BUG();
|
2011-12-09 11:14:27 +08:00
|
|
|
}
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2013-03-09 00:43:54 +08:00
|
|
|
int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin)
|
2013-02-15 05:35:09 +08:00
|
|
|
{
|
2013-02-15 08:33:38 +08:00
|
|
|
unsigned int offset;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (pfc->info->ranges == NULL)
|
2013-03-09 00:43:54 +08:00
|
|
|
return pin;
|
2013-02-15 08:33:38 +08:00
|
|
|
|
|
|
|
for (i = 0, offset = 0; i < pfc->info->nr_ranges; ++i) {
|
|
|
|
const struct pinmux_range *range = &pfc->info->ranges[i];
|
|
|
|
|
|
|
|
if (pin <= range->end)
|
|
|
|
return pin >= range->begin
|
2013-03-09 00:43:54 +08:00
|
|
|
? offset + pin - range->begin : -1;
|
2013-02-15 08:33:38 +08:00
|
|
|
|
|
|
|
offset += range->end - range->begin + 1;
|
|
|
|
}
|
|
|
|
|
2013-03-10 23:38:23 +08:00
|
|
|
return -EINVAL;
|
2013-02-15 05:35:09 +08:00
|
|
|
}
|
|
|
|
|
2013-02-17 01:47:05 +08:00
|
|
|
static int sh_pfc_enum_in_range(pinmux_enum_t enum_id,
|
|
|
|
const struct pinmux_range *r)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
|
|
|
if (enum_id < r->begin)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (enum_id > r->end)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-02-15 09:04:55 +08:00
|
|
|
unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
|
|
|
|
unsigned long reg_width)
|
2008-12-25 17:17:26 +08:00
|
|
|
{
|
|
|
|
switch (reg_width) {
|
|
|
|
case 8:
|
2011-12-09 11:14:27 +08:00
|
|
|
return ioread8(mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
case 16:
|
2011-12-09 11:14:27 +08:00
|
|
|
return ioread16(mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
case 32:
|
2011-12-09 11:14:27 +08:00
|
|
|
return ioread32(mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BUG();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-15 09:04:55 +08:00
|
|
|
void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width,
|
|
|
|
unsigned long data)
|
2008-12-25 17:17:26 +08:00
|
|
|
{
|
|
|
|
switch (reg_width) {
|
|
|
|
case 8:
|
2011-12-09 11:14:27 +08:00
|
|
|
iowrite8(data, mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
return;
|
|
|
|
case 16:
|
2011-12-09 11:14:27 +08:00
|
|
|
iowrite16(data, mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
return;
|
|
|
|
case 32:
|
2011-12-09 11:14:27 +08:00
|
|
|
iowrite32(data, mapped_reg);
|
2008-12-25 17:17:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
static void sh_pfc_config_reg_helper(struct sh_pfc *pfc,
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_cfg_reg *crp,
|
2012-12-16 06:50:53 +08:00
|
|
|
unsigned long in_pos,
|
|
|
|
void __iomem **mapped_regp,
|
|
|
|
unsigned long *maskp,
|
|
|
|
unsigned long *posp)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
2011-12-14 00:01:05 +08:00
|
|
|
int k;
|
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
*mapped_regp = sh_pfc_phys_to_virt(pfc, crp->reg);
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2011-12-14 00:01:05 +08:00
|
|
|
if (crp->field_width) {
|
|
|
|
*maskp = (1 << crp->field_width) - 1;
|
|
|
|
*posp = crp->reg_width - ((in_pos + 1) * crp->field_width);
|
|
|
|
} else {
|
|
|
|
*maskp = (1 << crp->var_field_width[in_pos]) - 1;
|
|
|
|
*posp = crp->reg_width;
|
|
|
|
for (k = 0; k <= in_pos; k++)
|
|
|
|
*posp -= crp->var_field_width[k];
|
|
|
|
}
|
2011-12-14 00:00:55 +08:00
|
|
|
}
|
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_cfg_reg *crp,
|
2012-12-16 06:50:53 +08:00
|
|
|
unsigned long field, unsigned long value)
|
2008-12-25 17:17:18 +08:00
|
|
|
{
|
2011-12-14 00:00:55 +08:00
|
|
|
void __iomem *mapped_reg;
|
2011-12-14 00:01:14 +08:00
|
|
|
unsigned long mask, pos, data;
|
2008-12-25 17:17:18 +08:00
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2011-12-14 00:00:55 +08:00
|
|
|
pr_debug("write_reg addr = %lx, value = %ld, field = %ld, "
|
2009-11-30 11:15:04 +08:00
|
|
|
"r_width = %ld, f_width = %ld\n",
|
2011-12-14 00:00:55 +08:00
|
|
|
crp->reg, value, field, crp->reg_width, crp->field_width);
|
2008-12-25 17:17:18 +08:00
|
|
|
|
|
|
|
mask = ~(mask << pos);
|
|
|
|
value = value << pos;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width);
|
2011-12-14 00:01:14 +08:00
|
|
|
data &= mask;
|
|
|
|
data |= value;
|
|
|
|
|
2012-12-16 06:51:20 +08:00
|
|
|
if (pfc->info->unlock_reg)
|
2012-12-16 06:50:53 +08:00
|
|
|
sh_pfc_write_raw_reg(
|
2012-12-16 06:51:20 +08:00
|
|
|
sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg), 32,
|
2012-12-16 06:50:53 +08:00
|
|
|
~data);
|
2011-12-14 00:01:14 +08:00
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data);
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
|
2012-12-16 06:50:53 +08:00
|
|
|
static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_cfg_reg **crp, int *fieldp,
|
2013-03-10 22:29:14 +08:00
|
|
|
int *valuep)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_cfg_reg *config_reg;
|
2011-12-14 00:01:05 +08:00
|
|
|
unsigned long r_width, f_width, curr_width, ncomb;
|
|
|
|
int k, m, n, pos, bit_pos;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
|
|
|
k = 0;
|
|
|
|
while (1) {
|
2012-12-16 06:51:20 +08:00
|
|
|
config_reg = pfc->info->cfg_regs + k;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
|
|
|
r_width = config_reg->reg_width;
|
|
|
|
f_width = config_reg->field_width;
|
|
|
|
|
|
|
|
if (!r_width)
|
|
|
|
break;
|
2011-12-14 00:01:05 +08:00
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
m = 0;
|
|
|
|
for (bit_pos = 0; bit_pos < r_width; bit_pos += curr_width) {
|
|
|
|
if (f_width)
|
|
|
|
curr_width = f_width;
|
|
|
|
else
|
|
|
|
curr_width = config_reg->var_field_width[m];
|
|
|
|
|
|
|
|
ncomb = 1 << curr_width;
|
|
|
|
for (n = 0; n < ncomb; n++) {
|
|
|
|
if (config_reg->enum_ids[pos + n] == enum_id) {
|
|
|
|
*crp = config_reg;
|
|
|
|
*fieldp = m;
|
|
|
|
*valuep = n;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
2011-12-14 00:01:05 +08:00
|
|
|
pos += ncomb;
|
|
|
|
m++;
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
2013-03-10 23:38:23 +08:00
|
|
|
return -EINVAL;
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
|
2013-02-15 00:36:56 +08:00
|
|
|
static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, pinmux_enum_t mark, int pos,
|
|
|
|
pinmux_enum_t *enum_idp)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
2013-02-17 01:47:05 +08:00
|
|
|
const pinmux_enum_t *data = pfc->info->gpio_data;
|
2008-10-08 19:41:43 +08:00
|
|
|
int k;
|
|
|
|
|
|
|
|
if (pos) {
|
|
|
|
*enum_idp = data[pos + 1];
|
|
|
|
return pos + 1;
|
|
|
|
}
|
|
|
|
|
2012-12-16 06:51:20 +08:00
|
|
|
for (k = 0; k < pfc->info->gpio_data_size; k++) {
|
2013-02-15 00:36:56 +08:00
|
|
|
if (data[k] == mark) {
|
2008-10-08 19:41:43 +08:00
|
|
|
*enum_idp = data[k + 1];
|
|
|
|
return k + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 00:36:56 +08:00
|
|
|
pr_err("cannot locate data/mark enum_id for mark %d\n", mark);
|
2013-03-10 23:38:23 +08:00
|
|
|
return -EINVAL;
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
|
2013-03-10 22:29:14 +08:00
|
|
|
int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_cfg_reg *cr = NULL;
|
2008-10-08 19:41:43 +08:00
|
|
|
pinmux_enum_t enum_id;
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct pinmux_range *range;
|
2011-12-14 00:00:46 +08:00
|
|
|
int in_range, pos, field, value;
|
2013-03-10 23:38:23 +08:00
|
|
|
int ret;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
|
|
|
switch (pinmux_type) {
|
|
|
|
|
|
|
|
case PINMUX_TYPE_FUNCTION:
|
|
|
|
range = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PINMUX_TYPE_OUTPUT:
|
2012-12-16 06:51:20 +08:00
|
|
|
range = &pfc->info->output;
|
2008-10-08 19:41:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PINMUX_TYPE_INPUT:
|
2012-12-16 06:51:20 +08:00
|
|
|
range = &pfc->info->input;
|
2008-10-08 19:41:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PINMUX_TYPE_INPUT_PULLUP:
|
2012-12-16 06:51:20 +08:00
|
|
|
range = &pfc->info->input_pu;
|
2008-10-08 19:41:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PINMUX_TYPE_INPUT_PULLDOWN:
|
2012-12-16 06:51:20 +08:00
|
|
|
range = &pfc->info->input_pd;
|
2008-10-08 19:41:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-03-10 23:38:23 +08:00
|
|
|
return -EINVAL;
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
enum_id = 0;
|
2011-12-14 00:00:46 +08:00
|
|
|
field = 0;
|
|
|
|
value = 0;
|
2008-10-08 19:41:43 +08:00
|
|
|
while (1) {
|
2013-02-15 00:36:56 +08:00
|
|
|
pos = sh_pfc_mark_to_enum(pfc, mark, pos, &enum_id);
|
2013-03-10 23:38:23 +08:00
|
|
|
if (pos < 0)
|
|
|
|
return pos;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
|
|
|
if (!enum_id)
|
|
|
|
break;
|
|
|
|
|
2010-01-19 21:52:28 +08:00
|
|
|
/* first check if this is a function enum */
|
2012-12-16 06:51:20 +08:00
|
|
|
in_range = sh_pfc_enum_in_range(enum_id, &pfc->info->function);
|
2010-01-19 21:52:28 +08:00
|
|
|
if (!in_range) {
|
|
|
|
/* not a function enum */
|
|
|
|
if (range) {
|
|
|
|
/*
|
|
|
|
* other range exists, so this pin is
|
|
|
|
* a regular GPIO pin that now is being
|
|
|
|
* bound to a specific direction.
|
|
|
|
*
|
|
|
|
* for this case we only allow function enums
|
|
|
|
* and the enums that match the other range.
|
|
|
|
*/
|
2012-12-16 06:50:53 +08:00
|
|
|
in_range = sh_pfc_enum_in_range(enum_id, range);
|
2010-01-19 21:52:28 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* special case pass through for fixed
|
|
|
|
* input-only or output-only pins without
|
|
|
|
* function enum register association.
|
|
|
|
*/
|
|
|
|
if (in_range && enum_id == range->force)
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* no other range exists, so this pin
|
|
|
|
* must then be of the function type.
|
|
|
|
*
|
|
|
|
* allow function type pins to select
|
|
|
|
* any combination of function/in/out
|
|
|
|
* in their MARK lists.
|
|
|
|
*/
|
|
|
|
in_range = 1;
|
|
|
|
}
|
2008-10-22 17:29:17 +08:00
|
|
|
}
|
|
|
|
|
2008-10-08 19:41:43 +08:00
|
|
|
if (!in_range)
|
|
|
|
continue;
|
|
|
|
|
2013-03-10 23:38:23 +08:00
|
|
|
ret = sh_pfc_get_config_reg(pfc, enum_id, &cr, &field, &value);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2013-03-10 22:29:14 +08:00
|
|
|
sh_pfc_write_config_reg(pfc, cr, field, value);
|
2008-10-08 19:41:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-16 06:50:47 +08:00
|
|
|
static int sh_pfc_probe(struct platform_device *pdev)
|
2008-10-08 19:41:43 +08:00
|
|
|
{
|
2013-02-17 01:47:05 +08:00
|
|
|
const struct sh_pfc_soc_info *info;
|
2012-12-16 06:50:47 +08:00
|
|
|
struct sh_pfc *pfc;
|
2008-12-25 17:17:18 +08:00
|
|
|
int ret;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2012-12-16 06:51:20 +08:00
|
|
|
info = pdev->id_entry->driver_data
|
|
|
|
? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data;
|
|
|
|
if (info == NULL)
|
2012-12-16 06:50:47 +08:00
|
|
|
return -ENODEV;
|
2008-10-08 19:41:43 +08:00
|
|
|
|
2013-02-14 20:23:47 +08:00
|
|
|
pfc = devm_kzalloc(&pdev->dev, sizeof(*pfc), GFP_KERNEL);
|
2012-12-16 06:50:47 +08:00
|
|
|
if (pfc == NULL)
|
|
|
|
return -ENOMEM;
|
2012-12-16 06:50:43 +08:00
|
|
|
|
2012-12-16 06:51:20 +08:00
|
|
|
pfc->info = info;
|
2012-12-16 06:50:47 +08:00
|
|
|
pfc->dev = &pdev->dev;
|
|
|
|
|
2012-12-16 06:50:55 +08:00
|
|
|
ret = sh_pfc_ioremap(pfc, pdev);
|
2012-12-16 06:50:47 +08:00
|
|
|
if (unlikely(ret < 0))
|
2011-12-09 11:14:27 +08:00
|
|
|
return ret;
|
|
|
|
|
2012-12-16 06:50:47 +08:00
|
|
|
spin_lock_init(&pfc->lock);
|
2008-12-25 17:17:34 +08:00
|
|
|
|
2012-07-10 11:08:14 +08:00
|
|
|
pinctrl_provide_dummies();
|
2011-12-09 11:14:27 +08:00
|
|
|
|
2012-07-10 11:08:14 +08:00
|
|
|
/*
|
|
|
|
* Initialize pinctrl bindings first
|
|
|
|
*/
|
2012-12-16 06:50:47 +08:00
|
|
|
ret = sh_pfc_register_pinctrl(pfc);
|
2012-12-16 06:50:45 +08:00
|
|
|
if (unlikely(ret != 0))
|
2012-12-16 06:50:49 +08:00
|
|
|
return ret;
|
2012-07-10 11:08:14 +08:00
|
|
|
|
2012-12-16 06:50:46 +08:00
|
|
|
#ifdef CONFIG_GPIO_SH_PFC
|
2012-07-10 11:08:14 +08:00
|
|
|
/*
|
|
|
|
* Then the GPIO chip
|
|
|
|
*/
|
2012-12-16 06:50:47 +08:00
|
|
|
ret = sh_pfc_register_gpiochip(pfc);
|
2012-12-16 06:50:46 +08:00
|
|
|
if (unlikely(ret != 0)) {
|
2012-07-10 11:08:14 +08:00
|
|
|
/*
|
|
|
|
* If the GPIO chip fails to come up we still leave the
|
|
|
|
* PFC state as it is, given that there are already
|
|
|
|
* extant users of it that have succeeded by this point.
|
|
|
|
*/
|
2012-12-16 06:50:46 +08:00
|
|
|
pr_notice("failed to init GPIO chip, ignoring...\n");
|
2012-06-20 16:29:04 +08:00
|
|
|
}
|
2012-12-16 06:50:46 +08:00
|
|
|
#endif
|
2010-10-04 02:54:56 +08:00
|
|
|
|
2012-12-16 06:50:47 +08:00
|
|
|
platform_set_drvdata(pdev, pfc);
|
|
|
|
|
2012-12-16 06:51:20 +08:00
|
|
|
pr_info("%s support registered\n", info->name);
|
2012-07-10 11:08:14 +08:00
|
|
|
|
2012-06-20 16:29:04 +08:00
|
|
|
return 0;
|
2010-10-04 02:54:56 +08:00
|
|
|
}
|
2012-12-16 06:50:46 +08:00
|
|
|
|
2012-12-16 06:50:47 +08:00
|
|
|
static int sh_pfc_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct sh_pfc *pfc = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
#ifdef CONFIG_GPIO_SH_PFC
|
|
|
|
sh_pfc_unregister_gpiochip(pfc);
|
|
|
|
#endif
|
|
|
|
sh_pfc_unregister_pinctrl(pfc);
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct platform_device_id sh_pfc_id_table[] = {
|
2012-12-16 06:51:21 +08:00
|
|
|
#ifdef CONFIG_PINCTRL_PFC_R8A7740
|
|
|
|
{ "pfc-r8a7740", (kernel_ulong_t)&r8a7740_pinmux_info },
|
2012-12-16 06:51:22 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_R8A7779
|
|
|
|
{ "pfc-r8a7779", (kernel_ulong_t)&r8a7779_pinmux_info },
|
2012-12-16 06:51:23 +08:00
|
|
|
#endif
|
2012-12-16 06:51:29 +08:00
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7203
|
|
|
|
{ "pfc-sh7203", (kernel_ulong_t)&sh7203_pinmux_info },
|
|
|
|
#endif
|
2012-12-16 06:51:30 +08:00
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7264
|
|
|
|
{ "pfc-sh7264", (kernel_ulong_t)&sh7264_pinmux_info },
|
|
|
|
#endif
|
2012-12-16 06:51:31 +08:00
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7269
|
|
|
|
{ "pfc-sh7269", (kernel_ulong_t)&sh7269_pinmux_info },
|
|
|
|
#endif
|
2012-12-16 06:51:23 +08:00
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7372
|
|
|
|
{ "pfc-sh7372", (kernel_ulong_t)&sh7372_pinmux_info },
|
2012-12-16 06:51:24 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH73A0
|
|
|
|
{ "pfc-sh73a0", (kernel_ulong_t)&sh73a0_pinmux_info },
|
2012-12-16 06:51:32 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7720
|
|
|
|
{ "pfc-sh7720", (kernel_ulong_t)&sh7720_pinmux_info },
|
2012-12-16 06:51:33 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7722
|
|
|
|
{ "pfc-sh7722", (kernel_ulong_t)&sh7722_pinmux_info },
|
2012-12-16 06:51:34 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7723
|
|
|
|
{ "pfc-sh7723", (kernel_ulong_t)&sh7723_pinmux_info },
|
2012-12-16 06:51:35 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7724
|
|
|
|
{ "pfc-sh7724", (kernel_ulong_t)&sh7724_pinmux_info },
|
2012-12-16 06:51:36 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7734
|
|
|
|
{ "pfc-sh7734", (kernel_ulong_t)&sh7734_pinmux_info },
|
2012-12-16 06:51:37 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7757
|
|
|
|
{ "pfc-sh7757", (kernel_ulong_t)&sh7757_pinmux_info },
|
2012-12-16 06:51:38 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7785
|
|
|
|
{ "pfc-sh7785", (kernel_ulong_t)&sh7785_pinmux_info },
|
2012-12-16 06:51:39 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SH7786
|
|
|
|
{ "pfc-sh7786", (kernel_ulong_t)&sh7786_pinmux_info },
|
2012-12-16 06:51:40 +08:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_PFC_SHX3
|
|
|
|
{ "pfc-shx3", (kernel_ulong_t)&shx3_pinmux_info },
|
2012-12-16 06:51:21 +08:00
|
|
|
#endif
|
2012-12-16 06:50:47 +08:00
|
|
|
{ "sh-pfc", 0 },
|
|
|
|
{ },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(platform, sh_pfc_id_table);
|
|
|
|
|
|
|
|
static struct platform_driver sh_pfc_driver = {
|
|
|
|
.probe = sh_pfc_probe,
|
|
|
|
.remove = sh_pfc_remove,
|
|
|
|
.id_table = sh_pfc_id_table,
|
|
|
|
.driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-12-16 06:50:54 +08:00
|
|
|
static int __init sh_pfc_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&sh_pfc_driver);
|
2012-12-16 06:50:47 +08:00
|
|
|
}
|
2012-12-16 06:50:54 +08:00
|
|
|
postcore_initcall(sh_pfc_init);
|
2012-12-16 06:50:47 +08:00
|
|
|
|
|
|
|
static void __exit sh_pfc_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&sh_pfc_driver);
|
|
|
|
}
|
|
|
|
module_exit(sh_pfc_exit);
|
|
|
|
|
2012-12-16 06:50:46 +08:00
|
|
|
MODULE_AUTHOR("Magnus Damm, Paul Mundt, Laurent Pinchart");
|
|
|
|
MODULE_DESCRIPTION("Pin Control and GPIO driver for SuperH pin function controller");
|
|
|
|
MODULE_LICENSE("GPL v2");
|