@@ -63,6 +63,7 @@ enum rockchip_pinctrl_type {
6363 RK3066B ,
6464 RK3188 ,
6565 RK3288 ,
66+ RK3368 ,
6667};
6768
6869/**
@@ -613,6 +614,68 @@ static void rk3288_calc_drv_reg_and_bit(struct rockchip_pin_bank *bank,
613614 }
614615}
615616
617+ #define RK3368_PULL_GRF_OFFSET 0x100
618+ #define RK3368_PULL_PMU_OFFSET 0x10
619+
620+ static void rk3368_calc_pull_reg_and_bit (struct rockchip_pin_bank * bank ,
621+ int pin_num , struct regmap * * regmap ,
622+ int * reg , u8 * bit )
623+ {
624+ struct rockchip_pinctrl * info = bank -> drvdata ;
625+
626+ /* The first 32 pins of the first bank are located in PMU */
627+ if (bank -> bank_num == 0 ) {
628+ * regmap = info -> regmap_pmu ;
629+ * reg = RK3368_PULL_PMU_OFFSET ;
630+
631+ * reg += ((pin_num / RK3188_PULL_PINS_PER_REG ) * 4 );
632+ * bit = pin_num % RK3188_PULL_PINS_PER_REG ;
633+ * bit *= RK3188_PULL_BITS_PER_PIN ;
634+ } else {
635+ * regmap = info -> regmap_base ;
636+ * reg = RK3368_PULL_GRF_OFFSET ;
637+
638+ /* correct the offset, as we're starting with the 2nd bank */
639+ * reg -= 0x10 ;
640+ * reg += bank -> bank_num * RK3188_PULL_BANK_STRIDE ;
641+ * reg += ((pin_num / RK3188_PULL_PINS_PER_REG ) * 4 );
642+
643+ * bit = (pin_num % RK3188_PULL_PINS_PER_REG );
644+ * bit *= RK3188_PULL_BITS_PER_PIN ;
645+ }
646+ }
647+
648+ #define RK3368_DRV_PMU_OFFSET 0x20
649+ #define RK3368_DRV_GRF_OFFSET 0x200
650+
651+ static void rk3368_calc_drv_reg_and_bit (struct rockchip_pin_bank * bank ,
652+ int pin_num , struct regmap * * regmap ,
653+ int * reg , u8 * bit )
654+ {
655+ struct rockchip_pinctrl * info = bank -> drvdata ;
656+
657+ /* The first 32 pins of the first bank are located in PMU */
658+ if (bank -> bank_num == 0 ) {
659+ * regmap = info -> regmap_pmu ;
660+ * reg = RK3368_DRV_PMU_OFFSET ;
661+
662+ * reg += ((pin_num / RK3288_DRV_PINS_PER_REG ) * 4 );
663+ * bit = pin_num % RK3288_DRV_PINS_PER_REG ;
664+ * bit *= RK3288_DRV_BITS_PER_PIN ;
665+ } else {
666+ * regmap = info -> regmap_base ;
667+ * reg = RK3368_DRV_GRF_OFFSET ;
668+
669+ /* correct the offset, as we're starting with the 2nd bank */
670+ * reg -= 0x10 ;
671+ * reg += bank -> bank_num * RK3288_DRV_BANK_STRIDE ;
672+ * reg += ((pin_num / RK3288_DRV_PINS_PER_REG ) * 4 );
673+
674+ * bit = (pin_num % RK3288_DRV_PINS_PER_REG );
675+ * bit *= RK3288_DRV_BITS_PER_PIN ;
676+ }
677+ }
678+
616679static int rockchip_perpin_drv_list [] = { 2 , 4 , 8 , 12 };
617680
618681static int rockchip_get_drive_perpin (struct rockchip_pin_bank * bank ,
@@ -703,6 +766,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num)
703766 : PIN_CONFIG_BIAS_DISABLE ;
704767 case RK3188 :
705768 case RK3288 :
769+ case RK3368 :
706770 data >>= bit ;
707771 data &= (1 << RK3188_PULL_BITS_PER_PIN ) - 1 ;
708772
@@ -758,6 +822,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
758822 break ;
759823 case RK3188 :
760824 case RK3288 :
825+ case RK3368 :
761826 spin_lock_irqsave (& bank -> slock , flags );
762827
763828 /* enable the write to the equivalent lower bits */
@@ -935,6 +1000,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
9351000 return pull ? false : true;
9361001 case RK3188 :
9371002 case RK3288 :
1003+ case RK3368 :
9381004 return (pull != PIN_CONFIG_BIAS_PULL_PIN_DEFAULT );
9391005 }
9401006
@@ -2068,6 +2134,29 @@ static struct rockchip_pin_ctrl rk3288_pin_ctrl = {
20682134 .drv_calc_reg = rk3288_calc_drv_reg_and_bit ,
20692135};
20702136
2137+ static struct rockchip_pin_bank rk3368_pin_banks [] = {
2138+ PIN_BANK_IOMUX_FLAGS (0 , 32 , "gpio0" , IOMUX_SOURCE_PMU ,
2139+ IOMUX_SOURCE_PMU ,
2140+ IOMUX_SOURCE_PMU ,
2141+ IOMUX_SOURCE_PMU
2142+ ),
2143+ PIN_BANK (1 , 32 , "gpio1" ),
2144+ PIN_BANK (2 , 32 , "gpio2" ),
2145+ PIN_BANK (3 , 32 , "gpio3" ),
2146+ };
2147+
2148+ static struct rockchip_pin_ctrl rk3368_pin_ctrl = {
2149+ .pin_banks = rk3368_pin_banks ,
2150+ .nr_banks = ARRAY_SIZE (rk3368_pin_banks ),
2151+ .label = "RK3368-GPIO" ,
2152+ .type = RK3368 ,
2153+ .grf_mux_offset = 0x0 ,
2154+ .pmu_mux_offset = 0x0 ,
2155+ .pull_calc_reg = rk3368_calc_pull_reg_and_bit ,
2156+ .drv_calc_reg = rk3368_calc_drv_reg_and_bit ,
2157+ };
2158+
2159+
20712160static const struct of_device_id rockchip_pinctrl_dt_match [] = {
20722161 { .compatible = "rockchip,rk2928-pinctrl" ,
20732162 .data = (void * )& rk2928_pin_ctrl },
@@ -2079,6 +2168,8 @@ static const struct of_device_id rockchip_pinctrl_dt_match[] = {
20792168 .data = (void * )& rk3188_pin_ctrl },
20802169 { .compatible = "rockchip,rk3288-pinctrl" ,
20812170 .data = (void * )& rk3288_pin_ctrl },
2171+ { .compatible = "rockchip,rk3368-pinctrl" ,
2172+ .data = (void * )& rk3368_pin_ctrl },
20822173 {},
20832174};
20842175MODULE_DEVICE_TABLE (of , rockchip_pinctrl_dt_match );
0 commit comments