@@ -73,6 +73,7 @@ enum jz_version {
73
73
struct ingenic_chip_info {
74
74
unsigned int num_chips ;
75
75
unsigned int reg_offset ;
76
+ enum jz_version version ;
76
77
77
78
const struct group_desc * groups ;
78
79
unsigned int num_groups ;
@@ -88,7 +89,6 @@ struct ingenic_pinctrl {
88
89
struct regmap * map ;
89
90
struct pinctrl_dev * pctl ;
90
91
struct pinctrl_pin_desc * pdesc ;
91
- enum jz_version version ;
92
92
93
93
const struct ingenic_chip_info * info ;
94
94
};
@@ -226,6 +226,7 @@ static const struct function_desc jz4740_functions[] = {
226
226
static const struct ingenic_chip_info jz4740_chip_info = {
227
227
.num_chips = 4 ,
228
228
.reg_offset = 0x100 ,
229
+ .version = ID_JZ4740 ,
229
230
.groups = jz4740_groups ,
230
231
.num_groups = ARRAY_SIZE (jz4740_groups ),
231
232
.functions = jz4740_functions ,
@@ -350,6 +351,7 @@ static const struct function_desc jz4725b_functions[] = {
350
351
static const struct ingenic_chip_info jz4725b_chip_info = {
351
352
.num_chips = 4 ,
352
353
.reg_offset = 0x100 ,
354
+ .version = ID_JZ4725B ,
353
355
.groups = jz4725b_groups ,
354
356
.num_groups = ARRAY_SIZE (jz4725b_groups ),
355
357
.functions = jz4725b_functions ,
@@ -604,6 +606,7 @@ static const struct function_desc jz4760_functions[] = {
604
606
static const struct ingenic_chip_info jz4760_chip_info = {
605
607
.num_chips = 6 ,
606
608
.reg_offset = 0x100 ,
609
+ .version = ID_JZ4760 ,
607
610
.groups = jz4760_groups ,
608
611
.num_groups = ARRAY_SIZE (jz4760_groups ),
609
612
.functions = jz4760_functions ,
@@ -615,6 +618,7 @@ static const struct ingenic_chip_info jz4760_chip_info = {
615
618
static const struct ingenic_chip_info jz4760b_chip_info = {
616
619
.num_chips = 6 ,
617
620
.reg_offset = 0x100 ,
621
+ .version = ID_JZ4760B ,
618
622
.groups = jz4760_groups ,
619
623
.num_groups = ARRAY_SIZE (jz4760_groups ),
620
624
.functions = jz4760_functions ,
@@ -894,6 +898,7 @@ static const struct function_desc jz4770_functions[] = {
894
898
static const struct ingenic_chip_info jz4770_chip_info = {
895
899
.num_chips = 6 ,
896
900
.reg_offset = 0x100 ,
901
+ .version = ID_JZ4770 ,
897
902
.groups = jz4770_groups ,
898
903
.num_groups = ARRAY_SIZE (jz4770_groups ),
899
904
.functions = jz4770_functions ,
@@ -1028,6 +1033,7 @@ static const struct function_desc jz4780_functions[] = {
1028
1033
static const struct ingenic_chip_info jz4780_chip_info = {
1029
1034
.num_chips = 6 ,
1030
1035
.reg_offset = 0x100 ,
1036
+ .version = ID_JZ4780 ,
1031
1037
.groups = jz4780_groups ,
1032
1038
.num_groups = ARRAY_SIZE (jz4780_groups ),
1033
1039
.functions = jz4780_functions ,
@@ -1285,6 +1291,7 @@ static const struct function_desc x1000_functions[] = {
1285
1291
static const struct ingenic_chip_info x1000_chip_info = {
1286
1292
.num_chips = 4 ,
1287
1293
.reg_offset = 0x100 ,
1294
+ .version = ID_X1000 ,
1288
1295
.groups = x1000_groups ,
1289
1296
.num_groups = ARRAY_SIZE (x1000_groups ),
1290
1297
.functions = x1000_functions ,
@@ -1296,6 +1303,7 @@ static const struct ingenic_chip_info x1000_chip_info = {
1296
1303
static const struct ingenic_chip_info x1000e_chip_info = {
1297
1304
.num_chips = 4 ,
1298
1305
.reg_offset = 0x100 ,
1306
+ .version = ID_X1000E ,
1299
1307
.groups = x1000_groups ,
1300
1308
.num_groups = ARRAY_SIZE (x1000_groups ),
1301
1309
.functions = x1000_functions ,
@@ -1409,6 +1417,7 @@ static const struct function_desc x1500_functions[] = {
1409
1417
static const struct ingenic_chip_info x1500_chip_info = {
1410
1418
.num_chips = 4 ,
1411
1419
.reg_offset = 0x100 ,
1420
+ .version = ID_X1500 ,
1412
1421
.groups = x1500_groups ,
1413
1422
.num_groups = ARRAY_SIZE (x1500_groups ),
1414
1423
.functions = x1500_functions ,
@@ -1624,6 +1633,7 @@ static const struct function_desc x1830_functions[] = {
1624
1633
static const struct ingenic_chip_info x1830_chip_info = {
1625
1634
.num_chips = 4 ,
1626
1635
.reg_offset = 0x1000 ,
1636
+ .version = ID_X1830 ,
1627
1637
.groups = x1830_groups ,
1628
1638
.num_groups = ARRAY_SIZE (x1830_groups ),
1629
1639
.functions = x1830_functions ,
@@ -1682,7 +1692,7 @@ static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
1682
1692
static void ingenic_gpio_set_value (struct ingenic_gpio_chip * jzgc ,
1683
1693
u8 offset , int value )
1684
1694
{
1685
- if (jzgc -> jzpc -> version >= ID_JZ4760 )
1695
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 )
1686
1696
ingenic_gpio_set_bit (jzgc , JZ4760_GPIO_PAT0 , offset , !!value );
1687
1697
else
1688
1698
ingenic_gpio_set_bit (jzgc , JZ4740_GPIO_DATA , offset , !!value );
@@ -1693,7 +1703,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1693
1703
{
1694
1704
u8 reg1 , reg2 ;
1695
1705
1696
- if (jzgc -> jzpc -> version >= ID_JZ4760 ) {
1706
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 ) {
1697
1707
reg1 = JZ4760_GPIO_PAT1 ;
1698
1708
reg2 = JZ4760_GPIO_PAT0 ;
1699
1709
} else {
@@ -1703,7 +1713,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1703
1713
1704
1714
switch (type ) {
1705
1715
case IRQ_TYPE_EDGE_RISING :
1706
- if (jzgc -> jzpc -> version >= ID_X1000 ) {
1716
+ if (jzgc -> jzpc -> info -> version >= ID_X1000 ) {
1707
1717
ingenic_gpio_shadow_set_bit (jzgc , reg2 , offset , true);
1708
1718
ingenic_gpio_shadow_set_bit (jzgc , reg1 , offset , true);
1709
1719
ingenic_gpio_shadow_set_bit_load (jzgc );
@@ -1713,7 +1723,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1713
1723
}
1714
1724
break ;
1715
1725
case IRQ_TYPE_EDGE_FALLING :
1716
- if (jzgc -> jzpc -> version >= ID_X1000 ) {
1726
+ if (jzgc -> jzpc -> info -> version >= ID_X1000 ) {
1717
1727
ingenic_gpio_shadow_set_bit (jzgc , reg2 , offset , false);
1718
1728
ingenic_gpio_shadow_set_bit (jzgc , reg1 , offset , true);
1719
1729
ingenic_gpio_shadow_set_bit_load (jzgc );
@@ -1723,7 +1733,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1723
1733
}
1724
1734
break ;
1725
1735
case IRQ_TYPE_LEVEL_HIGH :
1726
- if (jzgc -> jzpc -> version >= ID_X1000 ) {
1736
+ if (jzgc -> jzpc -> info -> version >= ID_X1000 ) {
1727
1737
ingenic_gpio_shadow_set_bit (jzgc , reg2 , offset , true);
1728
1738
ingenic_gpio_shadow_set_bit (jzgc , reg1 , offset , false);
1729
1739
ingenic_gpio_shadow_set_bit_load (jzgc );
@@ -1734,7 +1744,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1734
1744
break ;
1735
1745
case IRQ_TYPE_LEVEL_LOW :
1736
1746
default :
1737
- if (jzgc -> jzpc -> version >= ID_X1000 ) {
1747
+ if (jzgc -> jzpc -> info -> version >= ID_X1000 ) {
1738
1748
ingenic_gpio_shadow_set_bit (jzgc , reg2 , offset , false);
1739
1749
ingenic_gpio_shadow_set_bit (jzgc , reg1 , offset , false);
1740
1750
ingenic_gpio_shadow_set_bit_load (jzgc );
@@ -1768,7 +1778,7 @@ static void ingenic_gpio_irq_enable(struct irq_data *irqd)
1768
1778
struct ingenic_gpio_chip * jzgc = gpiochip_get_data (gc );
1769
1779
int irq = irqd -> hwirq ;
1770
1780
1771
- if (jzgc -> jzpc -> version >= ID_JZ4760 )
1781
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 )
1772
1782
ingenic_gpio_set_bit (jzgc , JZ4760_GPIO_INT , irq , true);
1773
1783
else
1774
1784
ingenic_gpio_set_bit (jzgc , JZ4740_GPIO_SELECT , irq , true);
@@ -1784,7 +1794,7 @@ static void ingenic_gpio_irq_disable(struct irq_data *irqd)
1784
1794
1785
1795
ingenic_gpio_irq_mask (irqd );
1786
1796
1787
- if (jzgc -> jzpc -> version >= ID_JZ4760 )
1797
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 )
1788
1798
ingenic_gpio_set_bit (jzgc , JZ4760_GPIO_INT , irq , false);
1789
1799
else
1790
1800
ingenic_gpio_set_bit (jzgc , JZ4740_GPIO_SELECT , irq , false);
@@ -1809,7 +1819,7 @@ static void ingenic_gpio_irq_ack(struct irq_data *irqd)
1809
1819
irq_set_type (jzgc , irq , IRQ_TYPE_EDGE_RISING );
1810
1820
}
1811
1821
1812
- if (jzgc -> jzpc -> version >= ID_JZ4760 )
1822
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 )
1813
1823
ingenic_gpio_set_bit (jzgc , JZ4760_GPIO_FLAG , irq , false);
1814
1824
else
1815
1825
ingenic_gpio_set_bit (jzgc , JZ4740_GPIO_DATA , irq , true);
@@ -1866,7 +1876,7 @@ static void ingenic_gpio_irq_handler(struct irq_desc *desc)
1866
1876
1867
1877
chained_irq_enter (irq_chip , desc );
1868
1878
1869
- if (jzgc -> jzpc -> version >= ID_JZ4760 )
1879
+ if (jzgc -> jzpc -> info -> version >= ID_JZ4760 )
1870
1880
flag = ingenic_gpio_read_reg (jzgc , JZ4760_GPIO_FLAG );
1871
1881
else
1872
1882
flag = ingenic_gpio_read_reg (jzgc , JZ4740_GPIO_FLAG );
@@ -1948,7 +1958,7 @@ static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
1948
1958
struct ingenic_pinctrl * jzpc = jzgc -> jzpc ;
1949
1959
unsigned int pin = gc -> base + offset ;
1950
1960
1951
- if (jzpc -> version >= ID_JZ4760 )
1961
+ if (jzpc -> info -> version >= ID_JZ4760 )
1952
1962
return ingenic_get_pin_config (jzpc , pin , JZ4760_GPIO_PAT1 );
1953
1963
1954
1964
if (ingenic_get_pin_config (jzpc , pin , JZ4740_GPIO_SELECT ))
@@ -1974,13 +1984,13 @@ static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
1974
1984
dev_dbg (jzpc -> dev , "set pin P%c%u to function %u\n" ,
1975
1985
'A' + offt , idx , func );
1976
1986
1977
- if (jzpc -> version >= ID_X1000 ) {
1987
+ if (jzpc -> info -> version >= ID_X1000 ) {
1978
1988
ingenic_shadow_config_pin (jzpc , pin , JZ4760_GPIO_INT , false);
1979
1989
ingenic_shadow_config_pin (jzpc , pin , GPIO_MSK , false);
1980
1990
ingenic_shadow_config_pin (jzpc , pin , JZ4760_GPIO_PAT1 , func & 0x2 );
1981
1991
ingenic_shadow_config_pin (jzpc , pin , JZ4760_GPIO_PAT0 , func & 0x1 );
1982
1992
ingenic_shadow_config_pin_load (jzpc , pin );
1983
- } else if (jzpc -> version >= ID_JZ4760 ) {
1993
+ } else if (jzpc -> info -> version >= ID_JZ4760 ) {
1984
1994
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_INT , false);
1985
1995
ingenic_config_pin (jzpc , pin , GPIO_MSK , false);
1986
1996
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_PAT1 , func & 0x2 );
@@ -2033,12 +2043,12 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
2033
2043
dev_dbg (pctldev -> dev , "set pin P%c%u to %sput\n" ,
2034
2044
'A' + offt , idx , input ? "in" : "out" );
2035
2045
2036
- if (jzpc -> version >= ID_X1000 ) {
2046
+ if (jzpc -> info -> version >= ID_X1000 ) {
2037
2047
ingenic_shadow_config_pin (jzpc , pin , JZ4760_GPIO_INT , false);
2038
2048
ingenic_shadow_config_pin (jzpc , pin , GPIO_MSK , true);
2039
2049
ingenic_shadow_config_pin (jzpc , pin , JZ4760_GPIO_PAT1 , input );
2040
2050
ingenic_shadow_config_pin_load (jzpc , pin );
2041
- } else if (jzpc -> version >= ID_JZ4760 ) {
2051
+ } else if (jzpc -> info -> version >= ID_JZ4760 ) {
2042
2052
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_INT , false);
2043
2053
ingenic_config_pin (jzpc , pin , GPIO_MSK , true);
2044
2054
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_PAT1 , input );
@@ -2068,7 +2078,7 @@ static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2068
2078
unsigned int offt = pin / PINS_PER_GPIO_CHIP ;
2069
2079
bool pull ;
2070
2080
2071
- if (jzpc -> version >= ID_JZ4760 )
2081
+ if (jzpc -> info -> version >= ID_JZ4760 )
2072
2082
pull = !ingenic_get_pin_config (jzpc , pin , JZ4760_GPIO_PEN );
2073
2083
else
2074
2084
pull = !ingenic_get_pin_config (jzpc , pin , JZ4740_GPIO_PULL_DIS );
@@ -2100,7 +2110,7 @@ static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2100
2110
static void ingenic_set_bias (struct ingenic_pinctrl * jzpc ,
2101
2111
unsigned int pin , unsigned int bias )
2102
2112
{
2103
- if (jzpc -> version >= ID_X1830 ) {
2113
+ if (jzpc -> info -> version >= ID_X1830 ) {
2104
2114
unsigned int idx = pin % PINS_PER_GPIO_CHIP ;
2105
2115
unsigned int half = PINS_PER_GPIO_CHIP / 2 ;
2106
2116
unsigned int idxh = pin % half * 2 ;
@@ -2118,7 +2128,7 @@ static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
2118
2128
REG_SET (X1830_GPIO_PEH ), bias << idxh );
2119
2129
}
2120
2130
2121
- } else if (jzpc -> version >= ID_JZ4760 ) {
2131
+ } else if (jzpc -> info -> version >= ID_JZ4760 ) {
2122
2132
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_PEN , !bias );
2123
2133
} else {
2124
2134
ingenic_config_pin (jzpc , pin , JZ4740_GPIO_PULL_DIS , !bias );
@@ -2128,7 +2138,7 @@ static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
2128
2138
static void ingenic_set_output_level (struct ingenic_pinctrl * jzpc ,
2129
2139
unsigned int pin , bool high )
2130
2140
{
2131
- if (jzpc -> version >= ID_JZ4760 )
2141
+ if (jzpc -> info -> version >= ID_JZ4760 )
2132
2142
ingenic_config_pin (jzpc , pin , JZ4760_GPIO_PAT0 , high );
2133
2143
else
2134
2144
ingenic_config_pin (jzpc , pin , JZ4740_GPIO_DATA , high );
@@ -2258,20 +2268,6 @@ static const struct regmap_config ingenic_pinctrl_regmap_config = {
2258
2268
.reg_stride = 4 ,
2259
2269
};
2260
2270
2261
- static const struct of_device_id ingenic_pinctrl_of_match [] = {
2262
- { .compatible = "ingenic,jz4740-pinctrl" , .data = (void * ) ID_JZ4740 },
2263
- { .compatible = "ingenic,jz4725b-pinctrl" , .data = (void * )ID_JZ4725B },
2264
- { .compatible = "ingenic,jz4760-pinctrl" , .data = (void * ) ID_JZ4760 },
2265
- { .compatible = "ingenic,jz4760b-pinctrl" , .data = (void * ) ID_JZ4760B },
2266
- { .compatible = "ingenic,jz4770-pinctrl" , .data = (void * ) ID_JZ4770 },
2267
- { .compatible = "ingenic,jz4780-pinctrl" , .data = (void * ) ID_JZ4780 },
2268
- { .compatible = "ingenic,x1000-pinctrl" , .data = (void * ) ID_X1000 },
2269
- { .compatible = "ingenic,x1000e-pinctrl" , .data = (void * ) ID_X1000E },
2270
- { .compatible = "ingenic,x1500-pinctrl" , .data = (void * ) ID_X1500 },
2271
- { .compatible = "ingenic,x1830-pinctrl" , .data = (void * ) ID_X1830 },
2272
- {},
2273
- };
2274
-
2275
2271
static const struct of_device_id ingenic_gpio_of_match [] __initconst = {
2276
2272
{ .compatible = "ingenic,jz4740-gpio" , },
2277
2273
{ .compatible = "ingenic,jz4760-gpio" , },
@@ -2391,29 +2387,7 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
2391
2387
}
2392
2388
2393
2389
jzpc -> dev = dev ;
2394
- jzpc -> version = (enum jz_version )of_device_get_match_data (dev );
2395
-
2396
- if (jzpc -> version >= ID_X1830 )
2397
- chip_info = & x1830_chip_info ;
2398
- else if (jzpc -> version >= ID_X1500 )
2399
- chip_info = & x1500_chip_info ;
2400
- else if (jzpc -> version >= ID_X1000E )
2401
- chip_info = & x1000e_chip_info ;
2402
- else if (jzpc -> version >= ID_X1000 )
2403
- chip_info = & x1000_chip_info ;
2404
- else if (jzpc -> version >= ID_JZ4780 )
2405
- chip_info = & jz4780_chip_info ;
2406
- else if (jzpc -> version >= ID_JZ4770 )
2407
- chip_info = & jz4770_chip_info ;
2408
- else if (jzpc -> version >= ID_JZ4760B )
2409
- chip_info = & jz4760b_chip_info ;
2410
- else if (jzpc -> version >= ID_JZ4760 )
2411
- chip_info = & jz4760_chip_info ;
2412
- else if (jzpc -> version >= ID_JZ4725B )
2413
- chip_info = & jz4725b_chip_info ;
2414
- else
2415
- chip_info = & jz4740_chip_info ;
2416
- jzpc -> info = chip_info ;
2390
+ jzpc -> info = chip_info = of_device_get_match_data (dev );
2417
2391
2418
2392
pctl_desc = devm_kzalloc (& pdev -> dev , sizeof (* pctl_desc ), GFP_KERNEL );
2419
2393
if (!pctl_desc )
@@ -2482,6 +2456,20 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
2482
2456
return 0 ;
2483
2457
}
2484
2458
2459
+ static const struct of_device_id ingenic_pinctrl_of_match [] = {
2460
+ { .compatible = "ingenic,jz4740-pinctrl" , .data = & jz4740_chip_info },
2461
+ { .compatible = "ingenic,jz4725b-pinctrl" , .data = & jz4725b_chip_info },
2462
+ { .compatible = "ingenic,jz4760-pinctrl" , .data = & jz4760_chip_info },
2463
+ { .compatible = "ingenic,jz4760b-pinctrl" , .data = & jz4760b_chip_info },
2464
+ { .compatible = "ingenic,jz4770-pinctrl" , .data = & jz4770_chip_info },
2465
+ { .compatible = "ingenic,jz4780-pinctrl" , .data = & jz4780_chip_info },
2466
+ { .compatible = "ingenic,x1000-pinctrl" , .data = & x1000_chip_info },
2467
+ { .compatible = "ingenic,x1000e-pinctrl" , .data = & x1000e_chip_info },
2468
+ { .compatible = "ingenic,x1500-pinctrl" , .data = & x1500_chip_info },
2469
+ { .compatible = "ingenic,x1830-pinctrl" , .data = & x1830_chip_info },
2470
+ {},
2471
+ };
2472
+
2485
2473
static struct platform_driver ingenic_pinctrl_driver = {
2486
2474
.driver = {
2487
2475
.name = "pinctrl-ingenic" ,
0 commit comments