@@ -60,6 +60,14 @@ static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
6060 .initial_brightness = 128 ,
6161};
6262
63+ static const struct software_node arizona_gpiochip_node = {
64+ .name = "arizona" ,
65+ };
66+
67+ static const struct software_node crystalcove_gpiochip_node = {
68+ .name = "gpio_crystalcove" ,
69+ };
70+
6371/* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */
6472
6573static const struct property_entry lenovo_yb1_x90_goodix_props [] = {
@@ -383,19 +391,26 @@ static const struct platform_device_info lenovo_yoga_tab2_830_1050_pdevs[] __ini
383391
384392#define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00"
385393
386- static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = {
387- .dev_id = LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ,
388- .table = {
389- GPIO_LOOKUP ("gpio_crystalcove" , 3 , "reset" , GPIO_ACTIVE_HIGH ),
390- GPIO_LOOKUP ("INT33FC:01" , 23 , "wlf,ldoena" , GPIO_ACTIVE_HIGH ),
391- GPIO_LOOKUP ("arizona" , 2 , "wlf,spkvdd-ena" , GPIO_ACTIVE_HIGH ),
392- GPIO_LOOKUP ("arizona" , 4 , "wlf,micd-pol" , GPIO_ACTIVE_LOW ),
393- { }
394- },
394+ static const struct property_entry lenovo_yoga_tab2_830_1050_wm1502_props [] = {
395+ PROPERTY_ENTRY_GPIO ("reset-gpios" ,
396+ & crystalcove_gpiochip_node , 3 , GPIO_ACTIVE_HIGH ),
397+ PROPERTY_ENTRY_GPIO ("wlf,ldoena-gpios" ,
398+ & baytrail_gpiochip_nodes [1 ], 23 , GPIO_ACTIVE_HIGH ),
399+ PROPERTY_ENTRY_GPIO ("wlf,spkvdd-ena-gpios" ,
400+ & arizona_gpiochip_node , 2 , GPIO_ACTIVE_HIGH ),
401+ PROPERTY_ENTRY_GPIO ("wlf,micd-pol-gpios" ,
402+ & arizona_gpiochip_node , 4 , GPIO_ACTIVE_LOW ),
403+ { }
404+ };
405+
406+ static const struct software_node lenovo_yoga_tab2_830_1050_wm5102 = {
407+ .properties = lenovo_yoga_tab2_830_1050_wm1502_props ,
395408};
396409
397- static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios [] = {
398- & lenovo_yoga_tab2_830_1050_codec_gpios ,
410+ static const struct software_node * lenovo_yoga_tab2_830_1050_swnodes [] = {
411+ & crystalcove_gpiochip_node ,
412+ & arizona_gpiochip_node ,
413+ & lenovo_yoga_tab2_830_1050_wm5102 ,
399414 NULL
400415};
401416
@@ -409,7 +424,6 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
409424 .pdev_count = ARRAY_SIZE (lenovo_yoga_tab2_830_1050_pdevs ),
410425 .gpio_button = & lenovo_yoga_tab2_830_1050_lid ,
411426 .gpio_button_count = 1 ,
412- .gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios ,
413427 .bat_swnode = & generic_lipo_hv_4v35_battery_node ,
414428 .modules = bq24190_modules ,
415429 .gpiochip_type = X86_GPIOCHIP_BAYTRAIL ,
@@ -469,6 +483,7 @@ static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map =
469483 PIN_MAP_MUX_GROUP (LENOVO_YOGA_TAB2_830_1050_CODEC_NAME , "codec_32khz_clk" ,
470484 "INT33FC:02" , "pmu_clk2_grp" , "pmu_clk" );
471485
486+ static struct device * lenovo_yoga_tab2_830_1050_codec_dev ;
472487static struct pinctrl * lenovo_yoga_tab2_830_1050_codec_pinctrl ;
473488static struct sys_off_handler * lenovo_yoga_tab2_830_1050_sys_off_handler ;
474489
@@ -495,12 +510,26 @@ static int __init lenovo_yoga_tab2_830_1050_init_codec(void)
495510 goto err_unregister_mappings ;
496511 }
497512
498- /* We're done with the codec_dev now */
499- put_device (codec_dev );
513+ ret = software_node_register_node_group (lenovo_yoga_tab2_830_1050_swnodes );
514+ if (ret ) {
515+ ret = dev_err_probe (codec_dev , ret , "registering software nodes\n" );
516+ goto err_put_pinctrl ;
517+ }
500518
519+ ret = device_add_software_node (codec_dev , & lenovo_yoga_tab2_830_1050_wm5102 );
520+ if (ret ) {
521+ ret = dev_err_probe (codec_dev , ret , "adding software node\n" );
522+ goto err_unregister_swnodes ;
523+ }
524+
525+ lenovo_yoga_tab2_830_1050_codec_dev = codec_dev ;
501526 lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl ;
502527 return 0 ;
503528
529+ err_unregister_swnodes :
530+ software_node_unregister_node_group (lenovo_yoga_tab2_830_1050_swnodes );
531+ err_put_pinctrl :
532+ pinctrl_put (lenovo_yoga_tab2_830_1050_codec_pinctrl );
504533err_unregister_mappings :
505534 pinctrl_unregister_mappings (& lenovo_yoga_tab2_830_1050_codec_pinctrl_map );
506535err_put_device :
@@ -548,6 +577,12 @@ static void lenovo_yoga_tab2_830_1050_exit(void)
548577{
549578 unregister_sys_off_handler (lenovo_yoga_tab2_830_1050_sys_off_handler );
550579
580+ if (lenovo_yoga_tab2_830_1050_codec_dev ) {
581+ device_remove_software_node (lenovo_yoga_tab2_830_1050_codec_dev );
582+ put_device (lenovo_yoga_tab2_830_1050_codec_dev );
583+ software_node_unregister_node_group (lenovo_yoga_tab2_830_1050_swnodes );
584+ }
585+
551586 if (lenovo_yoga_tab2_830_1050_codec_pinctrl ) {
552587 pinctrl_put (lenovo_yoga_tab2_830_1050_codec_pinctrl );
553588 pinctrl_unregister_mappings (& lenovo_yoga_tab2_830_1050_codec_pinctrl_map );
@@ -750,7 +785,6 @@ static struct gpiod_lookup_table lenovo_yoga_tab2_1380_fc_gpios = {
750785};
751786
752787static struct gpiod_lookup_table * const lenovo_yoga_tab2_1380_gpios [] = {
753- & lenovo_yoga_tab2_830_1050_codec_gpios ,
754788 & lenovo_yoga_tab2_1380_fc_gpios ,
755789 NULL
756790};
@@ -947,12 +981,34 @@ static struct arizona_pdata lenovo_yt3_wm5102_pdata = {
947981 },
948982};
949983
984+ static const struct property_entry lenovo_yt3_wm1502_props [] = {
985+ PROPERTY_ENTRY_GPIO ("wlf,spkvdd-ena-gpios" ,
986+ & cherryview_gpiochip_nodes [0 ], 75 , GPIO_ACTIVE_HIGH ),
987+ PROPERTY_ENTRY_GPIO ("wlf,ldoena-gpios" ,
988+ & cherryview_gpiochip_nodes [0 ], 81 , GPIO_ACTIVE_HIGH ),
989+ PROPERTY_ENTRY_GPIO ("reset-gpios" , & cherryview_gpiochip_nodes [0 ], 82 , GPIO_ACTIVE_HIGH ),
990+ PROPERTY_ENTRY_GPIO ("wlf,micd-pol-gpios" , & arizona_gpiochip_node , 2 , GPIO_ACTIVE_HIGH ),
991+ { }
992+ };
993+
994+ static const struct software_node lenovo_yt3_wm5102 = {
995+ .properties = lenovo_yt3_wm1502_props ,
996+ .name = "wm5102" ,
997+ };
998+
999+ static const struct software_node * lenovo_yt3_swnodes [] = {
1000+ & arizona_gpiochip_node ,
1001+ & lenovo_yt3_wm5102 ,
1002+ NULL
1003+ };
1004+
9501005static const struct x86_spi_dev_info lenovo_yt3_spi_devs [] __initconst = {
9511006 {
9521007 /* WM5102 codec */
9531008 .board_info = {
9541009 .modalias = "wm5102" ,
9551010 .platform_data = & lenovo_yt3_wm5102_pdata ,
1011+ .swnode = & lenovo_yt3_wm5102 ,
9561012 .max_speed_hz = 5000000 ,
9571013 },
9581014 .ctrl_path = "\\_SB_.PCI0.SPI1" ,
@@ -999,31 +1055,18 @@ static int __init lenovo_yt3_init(struct device *dev)
9991055 intel_soc_pmic_exec_mipi_pmic_seq_element (0x6e , 0x9b , 0x02 , 0xff );
10001056 intel_soc_pmic_exec_mipi_pmic_seq_element (0x6e , 0xa0 , 0x02 , 0xff );
10011057
1058+ ret = software_node_register_node_group (lenovo_yt3_swnodes );
1059+ if (ret )
1060+ return dev_err_probe (dev , ret , "registering software nodes\n" );
1061+
10021062 return 0 ;
10031063}
10041064
1005- static struct gpiod_lookup_table lenovo_yt3_wm5102_gpios = {
1006- .dev_id = "spi1.0" ,
1007- .table = {
1008- GPIO_LOOKUP ("INT33FF:00" , 75 , "wlf,spkvdd-ena" , GPIO_ACTIVE_HIGH ),
1009- GPIO_LOOKUP ("INT33FF:00" , 81 , "wlf,ldoena" , GPIO_ACTIVE_HIGH ),
1010- GPIO_LOOKUP ("INT33FF:00" , 82 , "reset" , GPIO_ACTIVE_HIGH ),
1011- GPIO_LOOKUP ("arizona" , 2 , "wlf,micd-pol" , GPIO_ACTIVE_HIGH ),
1012- { }
1013- },
1014- };
1015-
1016- static struct gpiod_lookup_table * const lenovo_yt3_gpios [] = {
1017- & lenovo_yt3_wm5102_gpios ,
1018- NULL
1019- };
1020-
10211065const struct x86_dev_info lenovo_yt3_info __initconst = {
10221066 .i2c_client_info = lenovo_yt3_i2c_clients ,
10231067 .i2c_client_count = ARRAY_SIZE (lenovo_yt3_i2c_clients ),
10241068 .spi_dev_info = lenovo_yt3_spi_devs ,
10251069 .spi_dev_count = ARRAY_SIZE (lenovo_yt3_spi_devs ),
1026- .gpiod_lookup_tables = lenovo_yt3_gpios ,
10271070 .gpiochip_type = X86_GPIOCHIP_CHERRYVIEW ,
10281071 .init = lenovo_yt3_init ,
10291072};
0 commit comments