diff options
author | Heiko Stübner <heiko@sntech.de> | 2014-06-15 19:37:23 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-07-11 08:08:28 -0400 |
commit | 95ec8ae4498e99efaf319700e3e7b40fb4a4afd6 (patch) | |
tree | 4b7d0da1241d7e047ef7e8f0efeea28b19325009 /drivers/pinctrl | |
parent | 03716e1dd01b0e761a7db8f82c81f11746a0ef97 (diff) |
pinctrl: rockchip: enable iomuxes from pmu space
The upcoming rk3288 moves some iomux settings to the pmu register space.
Therefore add a flag for this and adapt the mux functions accordingly.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-rockchip.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 07c06e7171e7..cfdeb81035b6 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
@@ -69,6 +69,7 @@ enum rockchip_pinctrl_type { | |||
69 | */ | 69 | */ |
70 | #define IOMUX_GPIO_ONLY BIT(0) | 70 | #define IOMUX_GPIO_ONLY BIT(0) |
71 | #define IOMUX_WIDTH_4BIT BIT(1) | 71 | #define IOMUX_WIDTH_4BIT BIT(1) |
72 | #define IOMUX_SOURCE_PMU BIT(2) | ||
72 | 73 | ||
73 | /** | 74 | /** |
74 | * @type: iomux variant using IOMUX_* constants | 75 | * @type: iomux variant using IOMUX_* constants |
@@ -153,7 +154,8 @@ struct rockchip_pin_ctrl { | |||
153 | u32 nr_pins; | 154 | u32 nr_pins; |
154 | char *label; | 155 | char *label; |
155 | enum rockchip_pinctrl_type type; | 156 | enum rockchip_pinctrl_type type; |
156 | int mux_offset; | 157 | int grf_mux_offset; |
158 | int pmu_mux_offset; | ||
157 | void (*pull_calc_reg)(struct rockchip_pin_bank *bank, | 159 | void (*pull_calc_reg)(struct rockchip_pin_bank *bank, |
158 | int pin_num, struct regmap **regmap, | 160 | int pin_num, struct regmap **regmap, |
159 | int *reg, u8 *bit); | 161 | int *reg, u8 *bit); |
@@ -376,6 +378,7 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) | |||
376 | { | 378 | { |
377 | struct rockchip_pinctrl *info = bank->drvdata; | 379 | struct rockchip_pinctrl *info = bank->drvdata; |
378 | int iomux_num = (pin / 8); | 380 | int iomux_num = (pin / 8); |
381 | struct regmap *regmap; | ||
379 | unsigned int val; | 382 | unsigned int val; |
380 | int reg, ret, mask; | 383 | int reg, ret, mask; |
381 | u8 bit; | 384 | u8 bit; |
@@ -386,6 +389,9 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) | |||
386 | if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) | 389 | if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) |
387 | return RK_FUNC_GPIO; | 390 | return RK_FUNC_GPIO; |
388 | 391 | ||
392 | regmap = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU) | ||
393 | ? info->regmap_pmu : info->regmap_base; | ||
394 | |||
389 | /* get basic quadrupel of mux registers and the correct reg inside */ | 395 | /* get basic quadrupel of mux registers and the correct reg inside */ |
390 | mask = (bank->iomux[iomux_num].type & IOMUX_WIDTH_4BIT) ? 0xf : 0x3; | 396 | mask = (bank->iomux[iomux_num].type & IOMUX_WIDTH_4BIT) ? 0xf : 0x3; |
391 | reg = bank->iomux[iomux_num].offset; | 397 | reg = bank->iomux[iomux_num].offset; |
@@ -397,7 +403,7 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) | |||
397 | bit = (pin % 8) * 2; | 403 | bit = (pin % 8) * 2; |
398 | } | 404 | } |
399 | 405 | ||
400 | ret = regmap_read(info->regmap_base, reg, &val); | 406 | ret = regmap_read(regmap, reg, &val); |
401 | if (ret) | 407 | if (ret) |
402 | return ret; | 408 | return ret; |
403 | 409 | ||
@@ -421,6 +427,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) | |||
421 | { | 427 | { |
422 | struct rockchip_pinctrl *info = bank->drvdata; | 428 | struct rockchip_pinctrl *info = bank->drvdata; |
423 | int iomux_num = (pin / 8); | 429 | int iomux_num = (pin / 8); |
430 | struct regmap *regmap; | ||
424 | int reg, ret, mask; | 431 | int reg, ret, mask; |
425 | unsigned long flags; | 432 | unsigned long flags; |
426 | u8 bit; | 433 | u8 bit; |
@@ -442,6 +449,9 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) | |||
442 | dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n", | 449 | dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n", |
443 | bank->bank_num, pin, mux); | 450 | bank->bank_num, pin, mux); |
444 | 451 | ||
452 | regmap = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU) | ||
453 | ? info->regmap_pmu : info->regmap_base; | ||
454 | |||
445 | /* get basic quadrupel of mux registers and the correct reg inside */ | 455 | /* get basic quadrupel of mux registers and the correct reg inside */ |
446 | mask = (bank->iomux[iomux_num].type & IOMUX_WIDTH_4BIT) ? 0xf : 0x3; | 456 | mask = (bank->iomux[iomux_num].type & IOMUX_WIDTH_4BIT) ? 0xf : 0x3; |
447 | reg = bank->iomux[iomux_num].offset; | 457 | reg = bank->iomux[iomux_num].offset; |
@@ -457,7 +467,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) | |||
457 | 467 | ||
458 | data = (mask << (bit + 16)); | 468 | data = (mask << (bit + 16)); |
459 | data |= (mux & mask) << bit; | 469 | data |= (mux & mask) << bit; |
460 | ret = regmap_write(info->regmap_base, reg, data); | 470 | ret = regmap_write(regmap, reg, data); |
461 | 471 | ||
462 | spin_unlock_irqrestore(&bank->slock, flags); | 472 | spin_unlock_irqrestore(&bank->slock, flags); |
463 | 473 | ||
@@ -1536,7 +1546,7 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( | |||
1536 | struct device_node *np; | 1546 | struct device_node *np; |
1537 | struct rockchip_pin_ctrl *ctrl; | 1547 | struct rockchip_pin_ctrl *ctrl; |
1538 | struct rockchip_pin_bank *bank; | 1548 | struct rockchip_pin_bank *bank; |
1539 | int grf_offs, i, j; | 1549 | int grf_offs, pmu_offs, i, j; |
1540 | 1550 | ||
1541 | match = of_match_node(rockchip_pinctrl_dt_match, node); | 1551 | match = of_match_node(rockchip_pinctrl_dt_match, node); |
1542 | ctrl = (struct rockchip_pin_ctrl *)match->data; | 1552 | ctrl = (struct rockchip_pin_ctrl *)match->data; |
@@ -1558,7 +1568,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( | |||
1558 | } | 1568 | } |
1559 | } | 1569 | } |
1560 | 1570 | ||
1561 | grf_offs = ctrl->mux_offset; | 1571 | grf_offs = ctrl->grf_mux_offset; |
1572 | pmu_offs = ctrl->pmu_mux_offset; | ||
1562 | bank = ctrl->pin_banks; | 1573 | bank = ctrl->pin_banks; |
1563 | for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { | 1574 | for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { |
1564 | int bank_pins = 0; | 1575 | int bank_pins = 0; |
@@ -1578,9 +1589,13 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( | |||
1578 | 1589 | ||
1579 | /* preset offset value, set new start value */ | 1590 | /* preset offset value, set new start value */ |
1580 | if (iom->offset >= 0) { | 1591 | if (iom->offset >= 0) { |
1581 | grf_offs = iom->offset; | 1592 | if (iom->type & IOMUX_SOURCE_PMU) |
1593 | pmu_offs = iom->offset; | ||
1594 | else | ||
1595 | grf_offs = iom->offset; | ||
1582 | } else { /* set current offset */ | 1596 | } else { /* set current offset */ |
1583 | iom->offset = grf_offs; | 1597 | iom->offset = (iom->type & IOMUX_SOURCE_PMU) ? |
1598 | pmu_offs : grf_offs; | ||
1584 | } | 1599 | } |
1585 | 1600 | ||
1586 | dev_dbg(d->dev, "bank %d, iomux %d has offset 0x%x\n", | 1601 | dev_dbg(d->dev, "bank %d, iomux %d has offset 0x%x\n", |
@@ -1591,7 +1606,10 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( | |||
1591 | * 4bit iomux'es are spread over two registers. | 1606 | * 4bit iomux'es are spread over two registers. |
1592 | */ | 1607 | */ |
1593 | inc = (iom->type & IOMUX_WIDTH_4BIT) ? 8 : 4; | 1608 | inc = (iom->type & IOMUX_WIDTH_4BIT) ? 8 : 4; |
1594 | grf_offs += inc; | 1609 | if (iom->type & IOMUX_SOURCE_PMU) |
1610 | pmu_offs += inc; | ||
1611 | else | ||
1612 | grf_offs += inc; | ||
1595 | 1613 | ||
1596 | bank_pins += 8; | 1614 | bank_pins += 8; |
1597 | } | 1615 | } |
@@ -1698,7 +1716,7 @@ static struct rockchip_pin_ctrl rk2928_pin_ctrl = { | |||
1698 | .nr_banks = ARRAY_SIZE(rk2928_pin_banks), | 1716 | .nr_banks = ARRAY_SIZE(rk2928_pin_banks), |
1699 | .label = "RK2928-GPIO", | 1717 | .label = "RK2928-GPIO", |
1700 | .type = RK2928, | 1718 | .type = RK2928, |
1701 | .mux_offset = 0xa8, | 1719 | .grf_mux_offset = 0xa8, |
1702 | .pull_calc_reg = rk2928_calc_pull_reg_and_bit, | 1720 | .pull_calc_reg = rk2928_calc_pull_reg_and_bit, |
1703 | }; | 1721 | }; |
1704 | 1722 | ||
@@ -1716,7 +1734,7 @@ static struct rockchip_pin_ctrl rk3066a_pin_ctrl = { | |||
1716 | .nr_banks = ARRAY_SIZE(rk3066a_pin_banks), | 1734 | .nr_banks = ARRAY_SIZE(rk3066a_pin_banks), |
1717 | .label = "RK3066a-GPIO", | 1735 | .label = "RK3066a-GPIO", |
1718 | .type = RK2928, | 1736 | .type = RK2928, |
1719 | .mux_offset = 0xa8, | 1737 | .grf_mux_offset = 0xa8, |
1720 | .pull_calc_reg = rk2928_calc_pull_reg_and_bit, | 1738 | .pull_calc_reg = rk2928_calc_pull_reg_and_bit, |
1721 | }; | 1739 | }; |
1722 | 1740 | ||
@@ -1732,7 +1750,7 @@ static struct rockchip_pin_ctrl rk3066b_pin_ctrl = { | |||
1732 | .nr_banks = ARRAY_SIZE(rk3066b_pin_banks), | 1750 | .nr_banks = ARRAY_SIZE(rk3066b_pin_banks), |
1733 | .label = "RK3066b-GPIO", | 1751 | .label = "RK3066b-GPIO", |
1734 | .type = RK3066B, | 1752 | .type = RK3066B, |
1735 | .mux_offset = 0x60, | 1753 | .grf_mux_offset = 0x60, |
1736 | }; | 1754 | }; |
1737 | 1755 | ||
1738 | static struct rockchip_pin_bank rk3188_pin_banks[] = { | 1756 | static struct rockchip_pin_bank rk3188_pin_banks[] = { |
@@ -1747,7 +1765,7 @@ static struct rockchip_pin_ctrl rk3188_pin_ctrl = { | |||
1747 | .nr_banks = ARRAY_SIZE(rk3188_pin_banks), | 1765 | .nr_banks = ARRAY_SIZE(rk3188_pin_banks), |
1748 | .label = "RK3188-GPIO", | 1766 | .label = "RK3188-GPIO", |
1749 | .type = RK3188, | 1767 | .type = RK3188, |
1750 | .mux_offset = 0x60, | 1768 | .grf_mux_offset = 0x60, |
1751 | .pull_calc_reg = rk3188_calc_pull_reg_and_bit, | 1769 | .pull_calc_reg = rk3188_calc_pull_reg_and_bit, |
1752 | }; | 1770 | }; |
1753 | 1771 | ||