Lines Matching refs:nvsw_sn2201

136 struct nvsw_sn2201 {  struct
892 nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201, in nvsw_sn2201_create_static_devices() argument
904 dev_err(nvsw_sn2201->dev, "Failed to create client %s at bus %d at addr 0x%02x\n", in nvsw_sn2201_create_static_devices()
926 static void nvsw_sn2201_destroy_static_devices(struct nvsw_sn2201 *nvsw_sn2201, in nvsw_sn2201_destroy_static_devices() argument
943 static int nvsw_sn2201_config_post_init(struct nvsw_sn2201 *nvsw_sn2201) in nvsw_sn2201_config_post_init() argument
950 dev = nvsw_sn2201->dev; in nvsw_sn2201_config_post_init()
951 adap = i2c_get_adapter(nvsw_sn2201->main_mux_deferred_nr); in nvsw_sn2201_config_post_init()
954 nvsw_sn2201->main_mux_deferred_nr); in nvsw_sn2201_config_post_init()
960 sn2201_dev = nvsw_sn2201->sn2201_devs; in nvsw_sn2201_config_post_init()
961 for (i = 0; i < nvsw_sn2201->sn2201_devs_num; i++, sn2201_dev++) { in nvsw_sn2201_config_post_init()
968 err = nvsw_sn2201_create_static_devices(nvsw_sn2201, nvsw_sn2201->sn2201_devs, in nvsw_sn2201_config_post_init()
969 nvsw_sn2201->sn2201_devs_num); in nvsw_sn2201_config_post_init()
976 static int nvsw_sn2201_config_init(struct nvsw_sn2201 *nvsw_sn2201, void *regmap) in nvsw_sn2201_config_init() argument
978 struct device *dev = nvsw_sn2201->dev; in nvsw_sn2201_config_init()
981 nvsw_sn2201->io_data = &nvsw_sn2201_regs_io; in nvsw_sn2201_config_init()
982 nvsw_sn2201->led_data = &nvsw_sn2201_led; in nvsw_sn2201_config_init()
983 nvsw_sn2201->wd_data = &nvsw_sn2201_wd; in nvsw_sn2201_config_init()
984 nvsw_sn2201->hotplug_data = &nvsw_sn2201_hotplug; in nvsw_sn2201_config_init()
987 if (nvsw_sn2201->io_data) { in nvsw_sn2201_config_init()
988 nvsw_sn2201->io_data->regmap = regmap; in nvsw_sn2201_config_init()
989 nvsw_sn2201->io_regs = in nvsw_sn2201_config_init()
991 nvsw_sn2201->io_data, in nvsw_sn2201_config_init()
992 sizeof(*nvsw_sn2201->io_data)); in nvsw_sn2201_config_init()
993 if (IS_ERR(nvsw_sn2201->io_regs)) { in nvsw_sn2201_config_init()
994 err = PTR_ERR(nvsw_sn2201->io_regs); in nvsw_sn2201_config_init()
1000 if (nvsw_sn2201->led_data) { in nvsw_sn2201_config_init()
1001 nvsw_sn2201->led_data->regmap = regmap; in nvsw_sn2201_config_init()
1002 nvsw_sn2201->led = in nvsw_sn2201_config_init()
1004 nvsw_sn2201->led_data, in nvsw_sn2201_config_init()
1005 sizeof(*nvsw_sn2201->led_data)); in nvsw_sn2201_config_init()
1006 if (IS_ERR(nvsw_sn2201->led)) { in nvsw_sn2201_config_init()
1007 err = PTR_ERR(nvsw_sn2201->led); in nvsw_sn2201_config_init()
1013 if (nvsw_sn2201->wd_data) { in nvsw_sn2201_config_init()
1014 nvsw_sn2201->wd_data->regmap = regmap; in nvsw_sn2201_config_init()
1015 nvsw_sn2201->wd = in nvsw_sn2201_config_init()
1017 nvsw_sn2201->wd_data, in nvsw_sn2201_config_init()
1018 sizeof(*nvsw_sn2201->wd_data)); in nvsw_sn2201_config_init()
1019 if (IS_ERR(nvsw_sn2201->wd)) { in nvsw_sn2201_config_init()
1020 err = PTR_ERR(nvsw_sn2201->wd); in nvsw_sn2201_config_init()
1026 if (nvsw_sn2201->hotplug_data) { in nvsw_sn2201_config_init()
1027 nvsw_sn2201->hotplug_data->regmap = regmap; in nvsw_sn2201_config_init()
1028 nvsw_sn2201->pdev_hotplug = in nvsw_sn2201_config_init()
1032 nvsw_sn2201->hotplug_data, in nvsw_sn2201_config_init()
1033 sizeof(*nvsw_sn2201->hotplug_data)); in nvsw_sn2201_config_init()
1034 if (IS_ERR(nvsw_sn2201->pdev_hotplug)) { in nvsw_sn2201_config_init()
1035 err = PTR_ERR(nvsw_sn2201->pdev_hotplug); in nvsw_sn2201_config_init()
1040 return nvsw_sn2201_config_post_init(nvsw_sn2201); in nvsw_sn2201_config_init()
1043 if (nvsw_sn2201->wd) in nvsw_sn2201_config_init()
1044 platform_device_unregister(nvsw_sn2201->wd); in nvsw_sn2201_config_init()
1046 if (nvsw_sn2201->led) in nvsw_sn2201_config_init()
1047 platform_device_unregister(nvsw_sn2201->led); in nvsw_sn2201_config_init()
1049 if (nvsw_sn2201->io_regs) in nvsw_sn2201_config_init()
1050 platform_device_unregister(nvsw_sn2201->io_regs); in nvsw_sn2201_config_init()
1056 static void nvsw_sn2201_config_exit(struct nvsw_sn2201 *nvsw_sn2201) in nvsw_sn2201_config_exit() argument
1059 if (nvsw_sn2201->pdev_hotplug) in nvsw_sn2201_config_exit()
1060 platform_device_unregister(nvsw_sn2201->pdev_hotplug); in nvsw_sn2201_config_exit()
1062 if (nvsw_sn2201->wd) in nvsw_sn2201_config_exit()
1063 platform_device_unregister(nvsw_sn2201->wd); in nvsw_sn2201_config_exit()
1065 if (nvsw_sn2201->led) in nvsw_sn2201_config_exit()
1066 platform_device_unregister(nvsw_sn2201->led); in nvsw_sn2201_config_exit()
1068 if (nvsw_sn2201->io_regs) in nvsw_sn2201_config_exit()
1069 platform_device_unregister(nvsw_sn2201->io_regs); in nvsw_sn2201_config_exit()
1082 struct nvsw_sn2201 *nvsw_sn2201 = handle; in nvsw_sn2201_i2c_completion_notify() local
1087 nvsw_sn2201->main_mux_devs->adapter = i2c_get_adapter(nvsw_sn2201->main_mux_devs->nr); in nvsw_sn2201_i2c_completion_notify()
1088 if (!nvsw_sn2201->main_mux_devs->adapter) { in nvsw_sn2201_i2c_completion_notify()
1090 dev_err(nvsw_sn2201->dev, "Failed to get adapter for bus %d\n", in nvsw_sn2201_i2c_completion_notify()
1091 nvsw_sn2201->cpld_devs->nr); in nvsw_sn2201_i2c_completion_notify()
1095 nvsw_sn2201->main_mux_devs_num = ARRAY_SIZE(nvsw_sn2201_main_mux_brdinfo); in nvsw_sn2201_i2c_completion_notify()
1096 err = nvsw_sn2201_create_static_devices(nvsw_sn2201, nvsw_sn2201->main_mux_devs, in nvsw_sn2201_i2c_completion_notify()
1097 nvsw_sn2201->main_mux_devs_num); in nvsw_sn2201_i2c_completion_notify()
1099 dev_err(nvsw_sn2201->dev, "Failed to create main mux devices\n"); in nvsw_sn2201_i2c_completion_notify()
1103 nvsw_sn2201->cpld_devs->adapter = i2c_get_adapter(nvsw_sn2201->cpld_devs->nr); in nvsw_sn2201_i2c_completion_notify()
1104 if (!nvsw_sn2201->cpld_devs->adapter) { in nvsw_sn2201_i2c_completion_notify()
1106 dev_err(nvsw_sn2201->dev, "Failed to get adapter for bus %d\n", in nvsw_sn2201_i2c_completion_notify()
1107 nvsw_sn2201->cpld_devs->nr); in nvsw_sn2201_i2c_completion_notify()
1112 nvsw_sn2201->cpld_devs->client = i2c_new_dummy_device(nvsw_sn2201->cpld_devs->adapter, in nvsw_sn2201_i2c_completion_notify()
1114 if (IS_ERR(nvsw_sn2201->cpld_devs->client)) { in nvsw_sn2201_i2c_completion_notify()
1115 err = PTR_ERR(nvsw_sn2201->cpld_devs->client); in nvsw_sn2201_i2c_completion_notify()
1116 dev_err(nvsw_sn2201->dev, "Failed to create %s cpld device at bus %d at addr 0x%02x\n", in nvsw_sn2201_i2c_completion_notify()
1117 nvsw_sn2201->cpld_devs->brdinfo->type, nvsw_sn2201->cpld_devs->nr, in nvsw_sn2201_i2c_completion_notify()
1118 nvsw_sn2201->cpld_devs->brdinfo->addr); in nvsw_sn2201_i2c_completion_notify()
1122 regmap = devm_regmap_init_i2c(nvsw_sn2201->cpld_devs->client, &nvsw_sn2201_regmap_conf); in nvsw_sn2201_i2c_completion_notify()
1125 dev_err(nvsw_sn2201->dev, "Failed to initialise managed register map\n"); in nvsw_sn2201_i2c_completion_notify()
1134 dev_err(nvsw_sn2201->dev, "Failed to set register at offset 0x%02x to default value: 0x%02x\n", in nvsw_sn2201_i2c_completion_notify()
1145 dev_err(nvsw_sn2201->dev, "Failed to Sync registers with hardware\n"); in nvsw_sn2201_i2c_completion_notify()
1150 err = nvsw_sn2201_config_init(nvsw_sn2201, regmap); in nvsw_sn2201_i2c_completion_notify()
1152 dev_err(nvsw_sn2201->dev, "Failed to configure board\n"); in nvsw_sn2201_i2c_completion_notify()
1159 nvsw_sn2201_config_exit(nvsw_sn2201); in nvsw_sn2201_i2c_completion_notify()
1164 i2c_put_adapter(nvsw_sn2201->cpld_devs->adapter); in nvsw_sn2201_i2c_completion_notify()
1165 nvsw_sn2201->cpld_devs->adapter = NULL; in nvsw_sn2201_i2c_completion_notify()
1168 nvsw_sn2201_destroy_static_devices(nvsw_sn2201, nvsw_sn2201->sn2201_devs, in nvsw_sn2201_i2c_completion_notify()
1169 nvsw_sn2201->sn2201_devs_num); in nvsw_sn2201_i2c_completion_notify()
1171 nvsw_sn2201_destroy_static_devices(nvsw_sn2201, nvsw_sn2201->main_mux_devs, in nvsw_sn2201_i2c_completion_notify()
1172 nvsw_sn2201->main_mux_devs_num); in nvsw_sn2201_i2c_completion_notify()
1174 i2c_put_adapter(nvsw_sn2201->main_mux_devs->adapter); in nvsw_sn2201_i2c_completion_notify()
1179 static int nvsw_sn2201_config_pre_init(struct nvsw_sn2201 *nvsw_sn2201) in nvsw_sn2201_config_pre_init() argument
1181 nvsw_sn2201->i2c_data = &nvsw_sn2201_i2c_data; in nvsw_sn2201_config_pre_init()
1184 nvsw_sn2201->i2c_data->handle = nvsw_sn2201; in nvsw_sn2201_config_pre_init()
1185 nvsw_sn2201->i2c_data->completion_notify = nvsw_sn2201_i2c_completion_notify; in nvsw_sn2201_config_pre_init()
1186 nvsw_sn2201->pdev_i2c = platform_device_register_resndata(nvsw_sn2201->dev, "i2c_mlxcpld", in nvsw_sn2201_config_pre_init()
1190 nvsw_sn2201->i2c_data, in nvsw_sn2201_config_pre_init()
1191 sizeof(*nvsw_sn2201->i2c_data)); in nvsw_sn2201_config_pre_init()
1192 if (IS_ERR(nvsw_sn2201->pdev_i2c)) in nvsw_sn2201_config_pre_init()
1193 return PTR_ERR(nvsw_sn2201->pdev_i2c); in nvsw_sn2201_config_pre_init()
1200 struct nvsw_sn2201 *nvsw_sn2201; in nvsw_sn2201_probe() local
1203 nvsw_sn2201 = devm_kzalloc(&pdev->dev, sizeof(*nvsw_sn2201), GFP_KERNEL); in nvsw_sn2201_probe()
1204 if (!nvsw_sn2201) in nvsw_sn2201_probe()
1207 nvsw_sn2201->dev = &pdev->dev; in nvsw_sn2201_probe()
1208 platform_set_drvdata(pdev, nvsw_sn2201); in nvsw_sn2201_probe()
1214 nvsw_sn2201->main_mux_deferred_nr = NVSW_SN2201_MAIN_MUX_DEFER_NR; in nvsw_sn2201_probe()
1215 nvsw_sn2201->main_mux_devs = nvsw_sn2201_main_mux_brdinfo; in nvsw_sn2201_probe()
1216 nvsw_sn2201->cpld_devs = nvsw_sn2201_cpld_brdinfo; in nvsw_sn2201_probe()
1217 nvsw_sn2201->sn2201_devs = nvsw_sn2201_static_brdinfo; in nvsw_sn2201_probe()
1218 nvsw_sn2201->sn2201_devs_num = ARRAY_SIZE(nvsw_sn2201_static_brdinfo); in nvsw_sn2201_probe()
1220 return nvsw_sn2201_config_pre_init(nvsw_sn2201); in nvsw_sn2201_probe()
1225 struct nvsw_sn2201 *nvsw_sn2201 = platform_get_drvdata(pdev); in nvsw_sn2201_remove() local
1228 nvsw_sn2201_config_exit(nvsw_sn2201); in nvsw_sn2201_remove()
1231 nvsw_sn2201_destroy_static_devices(nvsw_sn2201, in nvsw_sn2201_remove()
1232 nvsw_sn2201->sn2201_devs, in nvsw_sn2201_remove()
1233 nvsw_sn2201->sn2201_devs_num); in nvsw_sn2201_remove()
1235 i2c_put_adapter(nvsw_sn2201->cpld_devs->adapter); in nvsw_sn2201_remove()
1236 nvsw_sn2201->cpld_devs->adapter = NULL; in nvsw_sn2201_remove()
1238 nvsw_sn2201_destroy_static_devices(nvsw_sn2201, in nvsw_sn2201_remove()
1239 nvsw_sn2201->main_mux_devs, in nvsw_sn2201_remove()
1240 nvsw_sn2201->main_mux_devs_num); in nvsw_sn2201_remove()
1243 if (nvsw_sn2201->pdev_i2c) in nvsw_sn2201_remove()
1244 platform_device_unregister(nvsw_sn2201->pdev_i2c); in nvsw_sn2201_remove()