aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-rockchip.c
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2014-05-05 07:58:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-05-09 05:13:44 -0400
commitbfc7a42a0e74f0b589a017679620d2a3edda9198 (patch)
tree0d828632a20a38d6cfd09b090f07837b9f639257 /drivers/pinctrl/pinctrl-rockchip.c
parent9dffe1d4a7c2ee53b982ecb12c277040743d6ca2 (diff)
pinctrl: rockchip: do not require 2nd register area
Deprecate secondary register area for rk3188 pulls. Instead use big enough initial mapping of grf registers to catch all. The now deprecated register is still supported though. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Tested-by: Max Schwarz <max.schwarz@online.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-rockchip.c')
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 2e198a41c7bb..ab71de8bc7e0 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -160,6 +160,7 @@ struct rockchip_pmx_func {
160 160
161struct rockchip_pinctrl { 161struct rockchip_pinctrl {
162 void __iomem *reg_base; 162 void __iomem *reg_base;
163 int reg_size;
163 void __iomem *reg_pull; 164 void __iomem *reg_pull;
164 struct device *dev; 165 struct device *dev;
165 struct rockchip_pin_ctrl *ctrl; 166 struct rockchip_pin_ctrl *ctrl;
@@ -416,6 +417,7 @@ static void rk2928_calc_pull_reg_and_bit(struct rockchip_pin_bank *bank,
416 *bit = pin_num % RK2928_PULL_PINS_PER_REG; 417 *bit = pin_num % RK2928_PULL_PINS_PER_REG;
417}; 418};
418 419
420#define RK3188_PULL_OFFSET 0x164
419#define RK3188_PULL_BITS_PER_PIN 2 421#define RK3188_PULL_BITS_PER_PIN 2
420#define RK3188_PULL_PINS_PER_REG 8 422#define RK3188_PULL_PINS_PER_REG 8
421#define RK3188_PULL_BANK_STRIDE 16 423#define RK3188_PULL_BANK_STRIDE 16
@@ -432,7 +434,10 @@ static void rk3188_calc_pull_reg_and_bit(struct rockchip_pin_bank *bank,
432 *bit = pin_num % RK3188_PULL_PINS_PER_REG; 434 *bit = pin_num % RK3188_PULL_PINS_PER_REG;
433 *bit *= RK3188_PULL_BITS_PER_PIN; 435 *bit *= RK3188_PULL_BITS_PER_PIN;
434 } else { 436 } else {
435 *reg = info->reg_pull - 4; 437 *reg = info->reg_pull ? info->reg_pull
438 : info->reg_base + RK3188_PULL_OFFSET;
439 /* correct the offset, as it is the 2nd pull register */
440 *reg -= 4;
436 *reg += bank->bank_num * RK3188_PULL_BANK_STRIDE; 441 *reg += bank->bank_num * RK3188_PULL_BANK_STRIDE;
437 *reg += ((pin_num / RK3188_PULL_PINS_PER_REG) * 4); 442 *reg += ((pin_num / RK3188_PULL_PINS_PER_REG) * 4);
438 443
@@ -1427,6 +1432,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
1427 */ 1432 */
1428 if (of_device_is_compatible(bank->of_node, 1433 if (of_device_is_compatible(bank->of_node,
1429 "rockchip,rk3188-gpio-bank0")) { 1434 "rockchip,rk3188-gpio-bank0")) {
1435
1430 bank->bank_type = RK3188_BANK0; 1436 bank->bank_type = RK3188_BANK0;
1431 1437
1432 if (of_address_to_resource(bank->of_node, 1, &res)) { 1438 if (of_address_to_resource(bank->of_node, 1, &res)) {
@@ -1525,8 +1531,11 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
1525 if (IS_ERR(info->reg_base)) 1531 if (IS_ERR(info->reg_base))
1526 return PTR_ERR(info->reg_base); 1532 return PTR_ERR(info->reg_base);
1527 1533
1528 /* The RK3188 has its pull registers in a separate place */ 1534 /* to check for the old dt-bindings */
1529 if (ctrl->type == RK3188) { 1535 info->reg_size = resource_size(res);
1536
1537 /* Honor the old binding, with pull registers as 2nd resource */
1538 if (ctrl->type == RK3188 && info->reg_size < 0x200) {
1530 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1539 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1531 info->reg_pull = devm_ioremap_resource(&pdev->dev, res); 1540 info->reg_pull = devm_ioremap_resource(&pdev->dev, res);
1532 if (IS_ERR(info->reg_pull)) 1541 if (IS_ERR(info->reg_pull))