jtag: meson: fix jtag pinmux settings issue [2/2]

PD#SWPL-4501

Problem:
Standard pinmux APIs were not used

Solution:
Setting pinmux instead of require for gpio

Verify:
tl1,g12a,g12b,axg,txl,txlx,gxl

Change-Id: I0ad88f414832686d795d252f70e81a34f6cb0f9e
Signed-off-by: Yingyuan Zhu <yingyuan.zhu@amlogic.com>
This commit is contained in:
Yingyuan Zhu
2019-01-17 19:02:20 +08:00
committed by Luke Go
parent 6456487cc0
commit 3b0c4a5026
19 changed files with 449 additions and 363 deletions

View File

@@ -124,15 +124,10 @@
compatible = "amlogic, jtag";
status = "okay";
reg = <0xda004004 0x4>;
select = "apao"; /* disable apao apee */
jtagao-gpios = <&gpio_ao GPIOAO_8 0
&gpio_ao GPIOAO_9 0
&gpio_ao GPIOAO_10 0
&gpio_ao GPIOAO_11 0>;
jtagee-gpios = <&gpio CARD_0 0
&gpio CARD_1 0
&gpio CARD_2 0
&gpio CARD_3 0>;
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
securitykey {
@@ -623,6 +618,15 @@
bias-pull-up;
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};
};
pinctrl_aobus: pinctrl@c8100084 {
compatible = "amlogic,meson8b-aobus-pinctrl";
@@ -681,6 +685,15 @@
function = "spdif_2";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "GPIOAO_8",
"GPIOAO_9",
"GPIOAO_10",
"GPIOAO_11";
function = "gpio_aobus";
};
};
};
dwc2_b {
compatible = "amlogic,dwc2";

View File

@@ -282,6 +282,15 @@
status = "okay";
};
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
pinctrl_aobus: pinctrl@ff800014{
compatible = "amlogic,meson-axg-aobus-pinctrl";
#address-cells = <1>;
@@ -879,6 +888,16 @@
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_ao_tdi",
"jtag_ao_tdo",
"jtag_ao_clk",
"jtag_ao_tms";
function = "jtag_ao";
};
};
}; /* end of pinctrl_aobus */
&pinctrl_periphs {
@@ -1140,5 +1159,15 @@
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_tdo_x",
"jtag_tdi_x",
"jtag_clk_x",
"jtag_tms_x";
function = "jtag_ee";
};
};
}; /* end of pinctrl_periphs */

View File

@@ -448,15 +448,10 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio_ao GPIOAO_6 0
&gpio_ao GPIOAO_7 0
&gpio_ao GPIOAO_8 0
&gpio_ao GPIOAO_9 0>;
jtagee-gpios = <&gpio GPIOC_0 0
&gpio GPIOC_1 0
&gpio GPIOC_4 0
&gpio GPIOC_5 0>;
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
saradc:saradc {
@@ -1988,6 +1983,16 @@
function = "cec_ao";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {
@@ -2562,6 +2567,16 @@
drive-strength = <3>;
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_b_tdi",
"jtag_b_tdo",
"jtag_b_clk",
"jtag_b_tms";
function = "jtag_b";
};
};
};
&pinctrl_aobus {

View File

@@ -495,6 +495,15 @@
clocks = <&xtal>;
};
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
saradc:saradc {
compatible = "amlogic,meson-g12a-saradc";
status = "disabled";
@@ -2065,6 +2074,16 @@
function = "pwm_a_gpioe";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {
@@ -2572,6 +2591,16 @@
function = "remote_out";
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_b_tdi",
"jtag_b_tdo",
"jtag_b_clk",
"jtag_b_tms";
function = "jtag_b";
};
};
};
&gpu{

View File

@@ -250,15 +250,13 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio GPIOH_6 0
&gpio GPIOH_7 0
&gpio GPIOH_8 0
&gpio GPIOH_9 0>;
jtagee-gpios = <&gpio CARD_0 0
&gpio CARD_1 0
&gpio CARD_2 0
&gpio CARD_3 0>;
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXL platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_a_pins>;
pinctrl-1=<&jtag_b_pins>;
};
mailbox: mhu@c883c400 {
@@ -657,23 +655,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -240,15 +240,13 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio GPIOH_6 0
&gpio GPIOH_7 0
&gpio GPIOH_8 0
&gpio GPIOH_9 0>;
jtagee-gpios = <&gpio CARD_0 0
&gpio CARD_1 0
&gpio CARD_2 0
&gpio CARD_3 0>;
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXL platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_a_pins>;
pinctrl-1=<&jtag_b_pins>;
};
mailbox: mhu@c883c400 {
@@ -643,23 +641,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -284,10 +284,14 @@
jtag {
compatible = "amlogic, jtag";
status = "disabled";
status = "okay";
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXM platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names = "jtag_apao_pins", "jtag_apee_pins";
pinctrl-0 = <&jtag_apao_pins>;
pinctrl-1 = <&jtag_apee_pins>;
pinctrl-0 = <&jtag_a_pins>;
pinctrl-1 = <&jtag_b_pins>;
};
psci {
@@ -751,23 +755,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -1812,6 +1812,16 @@
function = "jtag_a";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {

View File

@@ -285,9 +285,13 @@
status = "okay";
};
amlogic-jtag {
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
vpu {
@@ -1040,6 +1044,16 @@
function = "i2c_ao";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "GPIOAO_3",
"GPIOAO_4",
"GPIOAO_5",
"GPIOAO_7";
function = "gpio_aobus";
};
};
};
&pinctrl_periphs {
@@ -1380,6 +1394,16 @@
function = "pwm_d";
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "GPIOC_0",
"GPIOC_1",
"GPIOC_2",
"GPIOC_3";
function = "gpio_periphs";
};
};
};
&gpu{

View File

@@ -287,6 +287,15 @@
status = "okay";
};
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
pinctrl_aobus: pinctrl@ff800014{
compatible = "amlogic,meson-axg-aobus-pinctrl";
#address-cells = <2>;
@@ -885,6 +894,15 @@
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_ao_tdi",
"jtag_ao_tdo",
"jtag_ao_clk",
"jtag_ao_tms";
function = "jtag_ao";
};
};
}; /* end of pinctrl_aobus */
&pinctrl_periphs {
@@ -1146,5 +1164,14 @@
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_tdo_x",
"jtag_tdi_x",
"jtag_clk_x",
"jtag_tms_x";
function = "jtag_ee";
};
};
}; /* end of pinctrl_periphs */

View File

@@ -448,15 +448,10 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio_ao GPIOAO_6 0
&gpio_ao GPIOAO_7 0
&gpio_ao GPIOAO_8 0
&gpio_ao GPIOAO_9 0>;
jtagee-gpios = <&gpio GPIOC_0 0
&gpio GPIOC_1 0
&gpio GPIOC_4 0
&gpio GPIOC_5 0>;
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
saradc:saradc {
@@ -1988,6 +1983,16 @@
function = "cec_ao";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {
@@ -2562,6 +2567,16 @@
drive-strength = <3>;
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_b_tdi",
"jtag_b_tdo",
"jtag_b_clk",
"jtag_b_tms";
function = "jtag_b";
};
};
};
&pinctrl_aobus {

View File

@@ -495,6 +495,15 @@
clocks = <&xtal>;
};
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
saradc:saradc {
compatible = "amlogic,meson-g12a-saradc";
status = "disabled";
@@ -2050,6 +2059,16 @@
function = "pwm_a_gpioe";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {
@@ -2557,6 +2576,16 @@
function = "remote_out";
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "jtag_b_tdi",
"jtag_b_tdo",
"jtag_b_clk",
"jtag_b_tms";
function = "jtag_b";
};
};
};
&gpu{

View File

@@ -237,15 +237,13 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio GPIOH_6 0
&gpio GPIOH_7 0
&gpio GPIOH_8 0
&gpio GPIOH_9 0>;
jtagee-gpios = <&gpio CARD_0 0
&gpio CARD_1 0
&gpio CARD_2 0
&gpio CARD_3 0>;
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXL platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_a_pins>;
pinctrl-1=<&jtag_b_pins>;
};
mailbox: mhu@c883c400 {
@@ -621,6 +619,7 @@
function = "ee_cec";
};
};
}; /* end of pinctrl_aobus*/
&pinctrl_periphs {
@@ -644,23 +643,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -240,15 +240,13 @@
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "apao"; /* disable/apao/apee */
jtagao-gpios = <&gpio GPIOH_6 0
&gpio GPIOH_7 0
&gpio GPIOH_8 0
&gpio GPIOH_9 0>;
jtagee-gpios = <&gpio CARD_0 0
&gpio CARD_1 0
&gpio CARD_2 0
&gpio CARD_3 0>;
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXL platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_a_pins>;
pinctrl-1=<&jtag_b_pins>;
};
mailbox: mhu@c883c400 {
@@ -643,23 +641,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -284,10 +284,14 @@
jtag {
compatible = "amlogic, jtag";
status = "disabled";
status = "okay";
select = "disable"; /* disable/apao/apee */
/* both sets of jtags for the GXM platform */
/* are in the ee domain, this is named apao */
/* just to match the jtag driver */
pinctrl-names = "jtag_apao_pins", "jtag_apee_pins";
pinctrl-0 = <&jtag_apao_pins>;
pinctrl-1 = <&jtag_apee_pins>;
pinctrl-0 = <&jtag_a_pins>;
pinctrl-1 = <&jtag_b_pins>;
};
psci {
@@ -751,23 +755,23 @@
};
};
jtag_apao_pins:jtag_apao_pin {
jtag_a_pins:jtag_a_pin {
mux {
groups = "jtag_tdi_0",
"jtag_tdo_0",
"jtag_clk_0",
"jtag_tms_0";
function = "jtag";
groups = "GPIOH_6",
"GPIOH_7",
"GPIOH_8",
"GPIOH_9";
function = "gpio_periphs";
};
};
jtag_apee_pins:jtag_apee_pin {
jtag_b_pins:jtag_b_pin {
mux {
groups ="jtag_tdi_1",
"jtag_tdo_1",
"jtag_clk_1",
"jtag_tms_1";
function = "jtag";
groups = "CARD_0",
"CARD_1",
"CARD_2",
"CARD_3";
function = "gpio_periphs";
};
};

View File

@@ -1811,6 +1811,16 @@
function = "jtag_a";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "jtag_a_tdi",
"jtag_a_tdo",
"jtag_a_clk",
"jtag_a_tms";
function = "jtag_a";
};
};
};
&pinctrl_periphs {

View File

@@ -285,9 +285,13 @@
status = "okay";
};
amlogic-jtag {
jtag {
compatible = "amlogic, jtag";
status = "okay";
select = "disable"; /* disable/apao/apee */
pinctrl-names="jtag_apao_pins", "jtag_apee_pins";
pinctrl-0=<&jtag_apao_pins>;
pinctrl-1=<&jtag_apee_pins>;
};
vpu {
@@ -1040,6 +1044,16 @@
function = "i2c_ao";
};
};
jtag_apao_pins:jtag_apao_pin {
mux {
groups = "GPIOAO_3",
"GPIOAO_4",
"GPIOAO_5",
"GPIOAO_7";
function = "gpio_aobus";
};
};
};
&pinctrl_periphs {
@@ -1380,6 +1394,16 @@
function = "pwm_d";
};
};
jtag_apee_pins:jtag_apee_pin {
mux {
groups = "GPIOC_0",
"GPIOC_1",
"GPIOC_2",
"GPIOC_3";
function = "gpio_periphs";
};
};
};
&gpu{

View File

@@ -101,6 +101,23 @@ static inline char *select_to_name(int select)
}
}
static inline int name_to_select(const char *s)
{
int select;
if (!strncmp(s, "disable", 7))
select = AMLOGIC_JTAG_DISABLE;
else if (!strncmp(s, "apao", 4))
select = AMLOGIC_JTAG_APAO;
else if (!strncmp(s, "apee", 4))
select = AMLOGIC_JTAG_APEE;
else {
pr_err("unknown select: %s\n", s);
select = AMLOGIC_JTAG_DISABLE;
}
return select;
}
static void aml_jtag_option_parse(struct aml_jtag_dev *jdev, const char *s)
{
@@ -108,15 +125,7 @@ static void aml_jtag_option_parse(struct aml_jtag_dev *jdev, const char *s)
unsigned long value;
int ret;
if (!strncmp(s, "disable", 7))
jdev->select = AMLOGIC_JTAG_DISABLE;
else if (!strncmp(s, "apao", 4))
jdev->select = AMLOGIC_JTAG_APAO;
else if (!strncmp(s, "apee", 4))
jdev->select = AMLOGIC_JTAG_APEE;
else
pr_err("unknown select: %s", s);
jdev->select = name_to_select(s);
cluster = strchr(s, ',');
if (cluster != NULL) {
cluster++;
@@ -138,19 +147,10 @@ static int __init setup_jtag(char *p)
unsigned long value;
int ret;
if (!p)
return -EINVAL;
jtag_select_setup = true;
if (!strncmp(p, "disable", 7))
jtag_select = AMLOGIC_JTAG_DISABLE;
else if (!strncmp(p, "apao", 4))
jtag_select = AMLOGIC_JTAG_APAO;
else if (!strncmp(p, "apee", 4))
jtag_select = AMLOGIC_JTAG_APEE;
else
jtag_select = AMLOGIC_JTAG_DISABLE;
pr_info("jtag select %s\n", select_to_name(jtag_select));
jtag_select = name_to_select(p);
cluster = strchr(p, ',');
if (cluster != NULL) {
cluster++;
@@ -176,97 +176,6 @@ static int __init setup_jtag(char *p)
*/
__setup("jtag=", setup_jtag);
/*
* request gpios for jtag apao.
*
* @return: 0 success, other failed
*
*/
static int aml_jtag_apao_request_gpios(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
const unsigned int *gpios = jdev->ao_gpios;
int ngpio, i, ret;
ngpio = jdev->ao_ngpios;
for (i = 0; i < ngpio; i++) {
ret = devm_gpio_request(dev, gpios[i], "apao");
if (ret) {
pr_err("can't request gpio %d", gpios[i]);
return -ENOENT;
}
pr_info("request gpio %d for apao\n", gpios[i]);
}
return 0;
}
static int aml_jtag_apao_free_gpios(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
const unsigned int *gpios = jdev->ao_gpios;
int ngpio, i;
ngpio = jdev->ao_ngpios;
for (i = 0; i < ngpio; i++)
devm_gpio_free(dev, gpios[i]);
return 0;
}
/*
* request gpios for jtag apee.
*
* @return: 0 success, other failed
*
*/
static int aml_jtag_apee_request_gpios(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
const unsigned int *gpios = jdev->ee_gpios;
int ngpio, i, ret;
ngpio = jdev->ee_ngpios;
for (i = 0; i < ngpio; i++) {
ret = devm_gpio_request(dev, gpios[i], "apee");
if (ret) {
pr_err("can't request gpio %d", gpios[i]);
return -ENOENT;
}
pr_info("request gpio %d for apee\n", gpios[i]);
}
return 0;
}
static int aml_jtag_apee_free_gpios(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
const unsigned int *gpios = jdev->ee_gpios;
int ngpio, i;
ngpio = jdev->ee_ngpios;
for (i = 0; i < ngpio; i++)
devm_gpio_free(dev, gpios[i]);
return 0;
}
#ifdef CONFIG_MACH_MESON8B
static int aml_jtag_select_tee(struct platform_device *pdev)
@@ -274,8 +183,8 @@ static int aml_jtag_select_tee(struct platform_device *pdev)
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
uint32_t select = jdev->select;
pr_info("set state %u\n", select);
set_cpus_allowed_ptr(current, cpumask_of(0));
pr_info("meson8b select %s\n", select_to_name(jdev->select));
switch (select) {
case AMLOGIC_JTAG_DISABLE:
meson_secure_jtag_disable();
@@ -309,7 +218,7 @@ static int aml_jtag_select_ree(struct platform_device *pdev)
pr_err("failed to iomap regs");
return -ENODEV;
}
pr_info("meson8b select %s\n", select_to_name(jdev->select));
switch (sel) {
case AMLOGIC_JTAG_DISABLE:
writel_relaxed(0x0, jdev->base);
@@ -353,6 +262,7 @@ static unsigned long __invoke_psci_fn_smc(unsigned long function_id,
struct arm_smccc_res res;
arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
return res.a0;
}
@@ -388,8 +298,7 @@ static int aml_jtag_select(struct platform_device *pdev)
if (jdev->cluster != CLUSTER_DISABLE)
select |= jdev->cluster << CLUSTER_BIT;
pr_info("set state %u\n", select);
pr_info("select %s\n", select_to_name(select));
set_cpus_allowed_ptr(current, cpumask_of(0));
aml_set_jtag_state(state, select);
set_cpus_allowed_ptr(current, cpu_all_mask);
@@ -399,43 +308,64 @@ static int aml_jtag_select(struct platform_device *pdev)
#endif
static void aml_jtag_setup(struct aml_jtag_dev *jdev)
static int aml_jtag_setup(struct aml_jtag_dev *jdev)
{
struct platform_device *pdev = jdev->pdev;
unsigned int old_select = jdev->old_select;
unsigned int select = jdev->select;
struct pinctrl_state *s;
int ret;
if (old_select == select)
return;
/* free gpios */
switch (old_select) {
case AMLOGIC_JTAG_APAO:
aml_jtag_apao_free_gpios(pdev);
break;
case AMLOGIC_JTAG_APEE:
aml_jtag_apee_free_gpios(pdev);
break;
default:
break;
return 0;
if (!jdev->jtag_pinctrl) {
jdev->jtag_pinctrl = devm_pinctrl_get(&jdev->pdev->dev);
if (IS_ERR_OR_NULL(jdev->jtag_pinctrl)) {
dev_err(&jdev->pdev->dev, "could not get pinctrl handle\n");
return -EINVAL;
}
}
/* free gpios */
/* set pinmux */
switch (select) {
case AMLOGIC_JTAG_APAO:
aml_jtag_apao_request_gpios(pdev);
s = pinctrl_lookup_state(jdev->jtag_pinctrl, "jtag_apao_pins");
if (IS_ERR_OR_NULL(s)) {
dev_err(&jdev->pdev->dev,
"could not get jtag_apao_pins state\n");
return -EINVAL;
}
ret = pinctrl_select_state(jdev->jtag_pinctrl, s);
if (ret) {
dev_err(&jdev->pdev->dev, "failed to set pinctrl\n");
return -EINVAL;
}
break;
case AMLOGIC_JTAG_APEE:
aml_jtag_apee_request_gpios(pdev);
s = pinctrl_lookup_state(jdev->jtag_pinctrl, "jtag_apee_pins");
if (IS_ERR_OR_NULL(s)) {
dev_err(&jdev->pdev->dev,
"could not get jtag_apee_pins state\n");
return -EINVAL;
}
ret = pinctrl_select_state(jdev->jtag_pinctrl, s);
if (ret) {
dev_err(&jdev->pdev->dev, "failed to set pinctrl\n");
return -EINVAL;
}
break;
default:
if (old_select != AMLOGIC_JTAG_DISABLE) {
devm_pinctrl_put(jdev->jtag_pinctrl);
jdev->jtag_pinctrl = NULL;
}
break;
}
/* save to global */
global_select = jdev->select;
aml_jtag_select(jdev->pdev);
jdev->old_select = select;
return 0;
}
static ssize_t jtag_select_show(struct class *cls,
@@ -448,23 +378,23 @@ static ssize_t jtag_select_show(struct class *cls,
len += sprintf(buf + len, "usage:\n");
len += sprintf(buf + len, " echo [apao|apee] > select\n");
len += sprintf(buf + len, " echo [apao|apee]{,[0|1]} > select\n");
return len;
}
static ssize_t jtag_select_store(struct class *cls,
struct class_attribute *attr,
const char *buffer, size_t count)
{
struct aml_jtag_dev *jdev;
int ret;
jdev = container_of(cls, struct aml_jtag_dev, cls);
aml_jtag_option_parse(jdev, buffer);
/* save to global */
global_select = jdev->select;
aml_jtag_setup(jdev);
ret = aml_jtag_setup(jdev);
if (ret < 0)
return ret;
return count;
}
@@ -474,63 +404,13 @@ static struct class_attribute aml_jtag_attrs[] = {
__ATTR_NULL,
};
static int aml_jtag_dt_parse(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
const char *tmp;
int ao_ngpios, ee_ngpios;
unsigned int *ao_gpios, *ee_gpios;
int ret, i, gpio;
ao_ngpios = of_gpio_named_count(np, "jtagao-gpios");
if (ao_ngpios <= 0) {
pr_err("ao gpios not specified\n");
return -EINVAL;
}
ee_ngpios = of_gpio_named_count(np, "jtagee-gpios");
if (ee_ngpios <= 0) {
pr_err("ee gpios not specified\n");
return -EINVAL;
}
jdev->ao_ngpios = ao_ngpios;
jdev->ee_ngpios = ee_ngpios;
ao_gpios = devm_kzalloc(dev, sizeof(unsigned int) * ao_ngpios,
GFP_KERNEL);
ee_gpios = devm_kzalloc(dev, sizeof(unsigned int) * ee_ngpios,
GFP_KERNEL);
if (!ao_gpios || !ee_gpios) {
pr_err("failed to allocate memory for gpios\n");
return -ENOMEM;
}
for (i = 0; i < ao_ngpios; i++) {
gpio = of_get_named_gpio(dev->of_node, "jtagao-gpios", i);
if (!gpio_is_valid(gpio)) {
pr_err("gpio %d is not valid", gpio);
return -EINVAL;
}
ao_gpios[i] = gpio;
}
for (i = 0; i < ee_ngpios; i++) {
gpio = of_get_named_gpio(dev->of_node, "jtagee-gpios", i);
if (!gpio_is_valid(gpio)) {
pr_err("gpio %d is not valid", gpio);
return -EINVAL;
}
ee_gpios[i] = gpio;
}
jdev->ao_gpios = ao_gpios;
jdev->ee_gpios = ee_gpios;
int ret;
/* otherwise set select with dt */
ret = of_property_read_string(np, "select", &tmp);
@@ -538,34 +418,22 @@ static int aml_jtag_dt_parse(struct platform_device *pdev)
pr_err("select not configured\n");
return -EINVAL;
}
pr_info("select is configured %s\n", tmp);
if (!strcmp(tmp, "disable"))
jdev->select = AMLOGIC_JTAG_DISABLE;
else if (!strcmp(tmp, "apao"))
jdev->select = AMLOGIC_JTAG_APAO;
else if (!strcmp(tmp, "apee"))
jdev->select = AMLOGIC_JTAG_APEE;
else
pr_err("unknown select: %s", tmp);
jdev->select = name_to_select(tmp);
return 0;
}
static int aml_jtag_probe(struct platform_device *pdev)
{
struct aml_jtag_dev *jdev;
int ret;
/* kzalloc device */
jdev = kzalloc(sizeof(struct aml_jtag_dev), GFP_KERNEL);
jdev = devm_kzalloc(&pdev->dev,
sizeof(struct aml_jtag_dev), GFP_KERNEL);
/* set driver data */
jdev->pdev = pdev;
platform_set_drvdata(pdev, jdev);
ret = aml_jtag_dt_parse(pdev);
if (ret)
return -EINVAL;
@@ -575,12 +443,8 @@ static int aml_jtag_probe(struct platform_device *pdev)
if (jtag_select_setup) {
jdev->select = jtag_select;
jdev->cluster = jtag_cluster;
pr_info("select is replaced by boot param\n");
}
/* save to global */
global_select = jdev->select;
/* create class attributes */
jdev->cls.name = AML_JTAG_NAME;
jdev->cls.owner = THIS_MODULE;
@@ -592,26 +456,25 @@ static int aml_jtag_probe(struct platform_device *pdev)
}
/* setup jtag */
aml_jtag_setup(jdev);
ret = aml_jtag_setup(jdev);
if (ret < 0) {
class_unregister(&jdev->cls);
return ret;
}
pr_info("module probed ok\n");
return 0;
}
static int __exit aml_jtag_remove(struct platform_device *pdev)
{
struct aml_jtag_dev *jdev = platform_get_drvdata(pdev);
class_unregister(&jdev->cls);
platform_set_drvdata(pdev, NULL);
kfree(jdev);
pr_info("module removed ok\n");
return 0;
}
static const struct of_device_id aml_jtag_dt_match[] = {
{
.compatible = "amlogic, jtag",
@@ -619,7 +482,6 @@ static const struct of_device_id aml_jtag_dt_match[] = {
{},
};
static struct platform_driver aml_jtag_driver = {
.driver = {
.name = AML_JTAG_NAME,
@@ -630,10 +492,8 @@ static struct platform_driver aml_jtag_driver = {
.remove = __exit_p(aml_jtag_remove),
};
static int __init aml_jtag_init(void)
{
pr_info("module init\n");
if (platform_driver_register(&aml_jtag_driver)) {
pr_err("failed to register driver\n");
return -ENODEV;
@@ -651,7 +511,6 @@ fs_initcall(aml_jtag_init);
static void __exit aml_jtag_exit(void)
{
pr_info("module exit\n");
platform_driver_unregister(&aml_jtag_driver);
}

View File

@@ -27,6 +27,7 @@
struct aml_jtag_dev {
struct platform_device *pdev;
struct pinctrl *jtag_pinctrl;
struct class cls;
#ifdef CONFIG_MACH_MESON8B