Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'platform-drivers-x86-ib-int3472-v6.7' of https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 into gpio/for-next

Immutable branch between pdx86 int3472 branch and GPIO due for the v6.7 merge window.

platform-drivers-x86-ib-int3472-v6.7: v6.6-rc1 + platform-drivers-x86-int3472
for merging into the GPIO subsystem for v6.7.

+93 -93
+8 -46
drivers/platform/x86/intel/int3472/clk_and_regulator.c
··· 162 162 } 163 163 164 164 int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472, 165 - struct acpi_resource_gpio *agpio, u32 polarity) 165 + struct gpio_desc *gpio) 166 166 { 167 - char *path = agpio->resource_source.string_ptr; 168 167 struct clk_init_data init = { 169 168 .ops = &skl_int3472_clock_ops, 170 169 .flags = CLK_GET_RATE_NOCACHE, ··· 173 174 if (int3472->clock.cl) 174 175 return -EBUSY; 175 176 176 - int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0], 177 - "int3472,clk-enable"); 178 - if (IS_ERR(int3472->clock.ena_gpio)) { 179 - ret = PTR_ERR(int3472->clock.ena_gpio); 180 - int3472->clock.ena_gpio = NULL; 181 - return dev_err_probe(int3472->dev, ret, "getting clk-enable GPIO\n"); 182 - } 183 - 184 - if (polarity == GPIO_ACTIVE_LOW) 185 - gpiod_toggle_active_low(int3472->clock.ena_gpio); 186 - 187 - /* Ensure the pin is in output mode and non-active state */ 188 - gpiod_direction_output(int3472->clock.ena_gpio, 0); 177 + int3472->clock.ena_gpio = gpio; 189 178 190 179 init.name = kasprintf(GFP_KERNEL, "%s-clk", 191 180 acpi_dev_name(int3472->adev)); 192 - if (!init.name) { 193 - ret = -ENOMEM; 194 - goto out_put_gpio; 195 - } 181 + if (!init.name) 182 + return -ENOMEM; 196 183 197 184 int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472); 198 185 ··· 204 219 clk_unregister(int3472->clock.clk); 205 220 out_free_init_name: 206 221 kfree(init.name); 207 - out_put_gpio: 208 - gpiod_put(int3472->clock.ena_gpio); 209 222 210 223 return ret; 211 224 } ··· 215 232 216 233 clkdev_drop(int3472->clock.cl); 217 234 clk_unregister(int3472->clock.clk); 218 - gpiod_put(int3472->clock.ena_gpio); 219 235 } 220 236 221 237 /* ··· 255 273 }; 256 274 257 275 int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, 258 - struct acpi_resource_gpio *agpio) 276 + struct gpio_desc *gpio) 259 277 { 260 - char *path = agpio->resource_source.string_ptr; 261 278 struct regulator_init_data init_data = { }; 262 279 struct regulator_config cfg = { }; 263 280 const char *second_sensor = NULL; 264 281 const struct dmi_system_id *id; 265 - int i, j, ret; 282 + int i, j; 266 283 267 284 id = dmi_first_match(skl_int3472_regulator_second_sensor); 268 285 if (id) ··· 295 314 int3472->regulator.supply_name, 296 315 &int3472_gpio_regulator_ops); 297 316 298 - int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0], 299 - "int3472,regulator"); 300 - if (IS_ERR(int3472->regulator.gpio)) { 301 - ret = PTR_ERR(int3472->regulator.gpio); 302 - int3472->regulator.gpio = NULL; 303 - return dev_err_probe(int3472->dev, ret, "getting regulator GPIO\n"); 304 - } 305 - 306 - /* Ensure the pin is in output mode and non-active state */ 307 - gpiod_direction_output(int3472->regulator.gpio, 0); 317 + int3472->regulator.gpio = gpio; 308 318 309 319 cfg.dev = &int3472->adev->dev; 310 320 cfg.init_data = &init_data; ··· 304 332 int3472->regulator.rdev = regulator_register(int3472->dev, 305 333 &int3472->regulator.rdesc, 306 334 &cfg); 307 - if (IS_ERR(int3472->regulator.rdev)) { 308 - ret = PTR_ERR(int3472->regulator.rdev); 309 - goto err_free_gpio; 310 - } 311 335 312 - return 0; 313 - 314 - err_free_gpio: 315 - gpiod_put(int3472->regulator.gpio); 316 - 317 - return ret; 336 + return PTR_ERR_OR_ZERO(int3472->regulator.rdev); 318 337 } 319 338 320 339 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472) 321 340 { 322 341 regulator_unregister(int3472->regulator.rdev); 323 - gpiod_put(int3472->regulator.gpio); 324 342 }
+3 -4
drivers/platform/x86/intel/int3472/common.h
··· 117 117 const char **name_ret); 118 118 119 119 int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472, 120 - struct acpi_resource_gpio *agpio, u32 polarity); 120 + struct gpio_desc *gpio); 121 121 int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472); 122 122 void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472); 123 123 124 124 int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, 125 - struct acpi_resource_gpio *agpio); 125 + struct gpio_desc *gpio); 126 126 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472); 127 127 128 - int skl_int3472_register_pled(struct int3472_discrete_device *int3472, 129 - struct acpi_resource_gpio *agpio, u32 polarity); 128 + int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio); 130 129 void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472); 131 130 132 131 #endif
+78 -23
drivers/platform/x86/intel/int3472/discrete.c
··· 52 52 } 53 53 } 54 54 55 - static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472, 56 - struct acpi_resource_gpio *agpio, 57 - const char *func, u32 polarity) 55 + static int skl_int3472_fill_gpiod_lookup(struct gpiod_lookup *table_entry, 56 + struct acpi_resource_gpio *agpio, 57 + const char *func, u32 polarity) 58 58 { 59 59 char *path = agpio->resource_source.string_ptr; 60 - struct gpiod_lookup *table_entry; 61 60 struct acpi_device *adev; 62 61 acpi_handle handle; 63 62 acpi_status status; 64 - 65 - if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) { 66 - dev_warn(int3472->dev, "Too many GPIOs mapped\n"); 67 - return -EINVAL; 68 - } 69 63 70 64 status = acpi_get_handle(NULL, path, &handle); 71 65 if (ACPI_FAILURE(status)) ··· 69 75 if (!adev) 70 76 return -ENODEV; 71 77 72 - table_entry = &int3472->gpios.table[int3472->n_sensor_gpios]; 73 78 table_entry->key = acpi_dev_name(adev); 74 79 table_entry->chip_hwnum = agpio->pin_table[0]; 75 80 table_entry->con_id = func; 76 81 table_entry->idx = 0; 77 82 table_entry->flags = polarity; 78 83 84 + return 0; 85 + } 86 + 87 + static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int3472, 88 + struct acpi_resource_gpio *agpio, 89 + const char *func, u32 polarity) 90 + { 91 + int ret; 92 + 93 + if (int3472->n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS) { 94 + dev_warn(int3472->dev, "Too many GPIOs mapped\n"); 95 + return -EINVAL; 96 + } 97 + 98 + ret = skl_int3472_fill_gpiod_lookup(&int3472->gpios.table[int3472->n_sensor_gpios], 99 + agpio, func, polarity); 100 + if (ret) 101 + return ret; 102 + 79 103 int3472->n_sensor_gpios++; 80 104 81 105 return 0; 106 + } 107 + 108 + /* This should *really* only be used when there's no other way... */ 109 + static struct gpio_desc * 110 + skl_int3472_gpiod_get_from_temp_lookup(struct int3472_discrete_device *int3472, 111 + struct acpi_resource_gpio *agpio, 112 + const char *func, u32 polarity) 113 + { 114 + struct gpio_desc *desc; 115 + int ret; 116 + 117 + struct gpiod_lookup_table *lookup __free(kfree) = 118 + kzalloc(struct_size(lookup, table, 2), GFP_KERNEL); 119 + if (!lookup) 120 + return ERR_PTR(-ENOMEM); 121 + 122 + lookup->dev_id = dev_name(int3472->dev); 123 + ret = skl_int3472_fill_gpiod_lookup(&lookup->table[0], agpio, func, polarity); 124 + if (ret) 125 + return ERR_PTR(ret); 126 + 127 + gpiod_add_lookup_table(lookup); 128 + desc = devm_gpiod_get(int3472->dev, func, GPIOD_OUT_LOW); 129 + gpiod_remove_lookup_table(lookup); 130 + 131 + return desc; 82 132 } 83 133 84 134 static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity) ··· 194 156 struct acpi_resource_gpio *agpio; 195 157 u8 active_value, pin, type; 196 158 union acpi_object *obj; 159 + struct gpio_desc *gpio; 197 160 const char *err_msg; 198 161 const char *func; 199 162 u32 polarity; ··· 245 206 246 207 break; 247 208 case INT3472_GPIO_TYPE_CLK_ENABLE: 248 - ret = skl_int3472_register_gpio_clock(int3472, agpio, polarity); 249 - if (ret) 250 - err_msg = "Failed to register clock\n"; 251 - 252 - break; 253 209 case INT3472_GPIO_TYPE_PRIVACY_LED: 254 - ret = skl_int3472_register_pled(int3472, agpio, polarity); 255 - if (ret) 256 - err_msg = "Failed to register LED\n"; 257 - 258 - break; 259 210 case INT3472_GPIO_TYPE_POWER_ENABLE: 260 - ret = skl_int3472_register_regulator(int3472, agpio); 261 - if (ret) 262 - err_msg = "Failed to map regulator to sensor\n"; 211 + gpio = skl_int3472_gpiod_get_from_temp_lookup(int3472, agpio, func, polarity); 212 + if (IS_ERR(gpio)) { 213 + ret = PTR_ERR(gpio); 214 + err_msg = "Failed to get GPIO\n"; 215 + break; 216 + } 263 217 218 + switch (type) { 219 + case INT3472_GPIO_TYPE_CLK_ENABLE: 220 + ret = skl_int3472_register_gpio_clock(int3472, gpio); 221 + if (ret) 222 + err_msg = "Failed to register clock\n"; 223 + 224 + break; 225 + case INT3472_GPIO_TYPE_PRIVACY_LED: 226 + ret = skl_int3472_register_pled(int3472, gpio); 227 + if (ret) 228 + err_msg = "Failed to register LED\n"; 229 + 230 + break; 231 + case INT3472_GPIO_TYPE_POWER_ENABLE: 232 + ret = skl_int3472_register_regulator(int3472, gpio); 233 + if (ret) 234 + err_msg = "Failed to map regulator to sensor\n"; 235 + 236 + break; 237 + default: /* Never reached */ 238 + ret = -EINVAL; 239 + break; 240 + } 264 241 break; 265 242 default: 266 243 dev_warn(int3472->dev,
+4 -20
drivers/platform/x86/intel/int3472/led.c
··· 16 16 return 0; 17 17 } 18 18 19 - int skl_int3472_register_pled(struct int3472_discrete_device *int3472, 20 - struct acpi_resource_gpio *agpio, u32 polarity) 19 + int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio) 21 20 { 22 - char *p, *path = agpio->resource_source.string_ptr; 21 + char *p; 23 22 int ret; 24 23 25 24 if (int3472->pled.classdev.dev) 26 25 return -EBUSY; 27 26 28 - int3472->pled.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0], 29 - "int3472,privacy-led"); 30 - if (IS_ERR(int3472->pled.gpio)) 31 - return dev_err_probe(int3472->dev, PTR_ERR(int3472->pled.gpio), 32 - "getting privacy LED GPIO\n"); 33 - 34 - if (polarity == GPIO_ACTIVE_LOW) 35 - gpiod_toggle_active_low(int3472->pled.gpio); 36 - 37 - /* Ensure the pin is in output mode and non-active state */ 38 - gpiod_direction_output(int3472->pled.gpio, 0); 27 + int3472->pled.gpio = gpio; 39 28 40 29 /* Generate the name, replacing the ':' in the ACPI devname with '_' */ 41 30 snprintf(int3472->pled.name, sizeof(int3472->pled.name), ··· 39 50 40 51 ret = led_classdev_register(int3472->dev, &int3472->pled.classdev); 41 52 if (ret) 42 - goto err_free_gpio; 53 + return ret; 43 54 44 55 int3472->pled.lookup.provider = int3472->pled.name; 45 56 int3472->pled.lookup.dev_id = int3472->sensor_name; ··· 47 58 led_add_lookup(&int3472->pled.lookup); 48 59 49 60 return 0; 50 - 51 - err_free_gpio: 52 - gpiod_put(int3472->pled.gpio); 53 - return ret; 54 61 } 55 62 56 63 void skl_int3472_unregister_pled(struct int3472_discrete_device *int3472) ··· 56 71 57 72 led_remove_lookup(&int3472->pled.lookup); 58 73 led_classdev_unregister(&int3472->pled.classdev); 59 - gpiod_put(int3472->pled.gpio); 60 74 }