Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3352978imu; Sun, 11 Nov 2018 13:03:12 -0800 (PST) X-Google-Smtp-Source: AJdET5eqs9/s1x2Qw13H9MMyzPZsGa4sWRrkpUlpCF7br2KvpT2IlSoAdTQz9o/SjkbVdmn65gT5 X-Received: by 2002:a62:ea10:: with SMTP id t16-v6mr18388809pfh.228.1541970192536; Sun, 11 Nov 2018 13:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541970192; cv=none; d=google.com; s=arc-20160816; b=JFrGxTrCt4rTd1UOIAD6ESOHxoga/9N5g9VTCBU9jD4SGdTjWLSet7OakTrnTsev+I kU3OYQF7D9k4DL8+A942EM5wfDIQ9AKHbZ09mGCt0xouS7ytnWsW0+NciaGMXLCoRQ6M ct1SnJUkGRHAMBUzg4VwBqXBvN/CjvrrKGQPPsDN9+z/xAH4eLFZfizkNgqpPI6A97lQ gVkbeh8aYH3jmjEBDIzgWyWQxc6mYWKV2peFeiknkGtnO0z9TJYIcmBELGcnm7tPKkd5 fml7q6bz5qsFiP6wmEtSpP5F/3ytUIVlzIFNWmJGrT7jp6L+jux9Cipm3aKdIriEE2ge oW5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=4+auq1xPW/isUUY69jzQrarB81YpsAayDK2nsD+n80g=; b=KcIicI2pRMxTaTmmzhpLXLOVXRt5tZB80FQZ+7uJC85Rzh9WipO0WufET7cLah//Ti PdeMMM4tz+QwP7/uSBxl+hQ2sn6ZZr3dKZOy0OAdZ7AXdg0jxhZggnxRxZ+vGurhIHf5 fNSmRm/GW5/EV+HyqY+1H7INk5w1sXAoGLGepc2HAIMBwU2R32shyFfQiGT/bHwO3jDK IpIDuawaFROFr9NlkkE1PgaM8WqmqzxgoTTZeXktXO9pn6BnZg/gNmq7P7WXWJ0NOfh6 bP9ZsC5dSNOu9V3T6tvYbxalJgwobDHJ0vWCU8QhrpGbTDg4w7aPMrxlKg/gOaPqAMtQ hSTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22si14361753pgr.356.2018.11.11.13.02.56; Sun, 11 Nov 2018 13:03:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729759AbeKLGuw (ORCPT + 99 others); Mon, 12 Nov 2018 01:50:52 -0500 Received: from gloria.sntech.de ([185.11.138.130]:44332 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbeKLGuv (ORCPT ); Mon, 12 Nov 2018 01:50:51 -0500 Received: from p54b264b4.dip0.t-ipconnect.de ([84.178.100.180] helo=phil.fritz.box) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1gLwqv-0001eN-WF; Sun, 11 Nov 2018 22:01:06 +0100 From: Heiko Stuebner To: linus.walleij@linaro.org Cc: heiko@sntech.de, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, shawn.lin@rock-chips.com, david.wu@rock-chips.com, Heiko Stuebner Subject: [PATCH 1/2] pinctrl: rockchip: allow specifying the regmap location for pin-routes Date: Sun, 11 Nov 2018 22:00:46 +0100 Message-Id: <20181111210047.30375-1-heiko@sntech.de> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Stuebner Right now we expect the pin-rounting settings to be in the same area as the iomux setting itself. And while that seems to be true for all newer Rockchip socs, back in the wild west days of old this wasn't true. Nowadays pin settings in the GRF normally stay in the GRF and the same is true for pins configured from PMU registers. But old socs like the rk3188 really sprinkle pin settings somewhat randomly through both for its bank0. Therefore add the option to specify a location for the route setting, so that we can map older socs correctly. We'll keep "same" as the default, so that we only need to specify a location in the corner-cases described above. Signed-off-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 95e4a06de019..246bf14c7f72 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -307,6 +307,12 @@ struct rockchip_mux_recalced_data { u8 mask; }; +enum rockchip_mux_route_location { + ROCKCHIP_ROUTE_SAME = 0, + ROCKCHIP_ROUTE_PMU, + ROCKCHIP_ROUTE_GRF, +}; + /** * struct rockchip_mux_recalced_data: represent a pin iomux data. * @bank_num: bank number. @@ -319,6 +325,7 @@ struct rockchip_mux_route_data { u8 bank_num; u8 pin; u8 func; + enum rockchip_mux_route_location route_location; u32 route_offset; u32 route_val; }; @@ -1091,7 +1098,7 @@ static struct rockchip_mux_route_data rk3399_mux_route_data[] = { }; static bool rockchip_get_mux_route(struct rockchip_pin_bank *bank, int pin, - int mux, u32 *reg, u32 *value) + int mux, u32 *loc, u32 *reg, u32 *value) { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; @@ -1108,6 +1115,7 @@ static bool rockchip_get_mux_route(struct rockchip_pin_bank *bank, int pin, if (i >= ctrl->niomux_routes) return false; + *loc = data->route_location; *reg = data->route_offset; *value = data->route_val; @@ -1210,7 +1218,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) struct regmap *regmap; int reg, ret, mask, mux_type; u8 bit; - u32 data, rmask, route_reg, route_val; + u32 data, rmask, route_location, route_reg, route_val; ret = rockchip_verify_mux(bank, pin, mux); if (ret < 0) @@ -1247,9 +1255,21 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) rockchip_get_recalced_mux(bank, pin, ®, &bit, &mask); if (bank->route_mask & BIT(pin)) { - if (rockchip_get_mux_route(bank, pin, mux, &route_reg, - &route_val)) { - ret = regmap_write(regmap, route_reg, route_val); + if (rockchip_get_mux_route(bank, pin, mux, &route_location, + &route_reg, &route_val)) { + struct regmap *route_regmap = regmap; + + /* handle special locations */ + switch (route_location) { + case ROCKCHIP_ROUTE_PMU: + route_regmap = info->regmap_pmu; + break; + case ROCKCHIP_ROUTE_GRF: + route_regmap = info->regmap_base; + break; + } + + ret = regmap_write(route_regmap, route_reg, route_val); if (ret) return ret; } -- 2.18.0