| .. | .. |
|---|
| 55 | 55 | #define HI3660_TEMP_STEP (205) |
|---|
| 56 | 56 | #define HI3660_TEMP_LAG (4000) |
|---|
| 57 | 57 | |
|---|
| 58 | | -#define HI6220_DEFAULT_SENSOR 2 |
|---|
| 59 | | -#define HI3660_DEFAULT_SENSOR 1 |
|---|
| 58 | +#define HI6220_CLUSTER0_SENSOR 2 |
|---|
| 59 | +#define HI6220_CLUSTER1_SENSOR 1 |
|---|
| 60 | + |
|---|
| 61 | +#define HI3660_LITTLE_SENSOR 0 |
|---|
| 62 | +#define HI3660_BIG_SENSOR 1 |
|---|
| 63 | +#define HI3660_G3D_SENSOR 2 |
|---|
| 64 | +#define HI3660_MODEM_SENSOR 3 |
|---|
| 65 | + |
|---|
| 66 | +struct hisi_thermal_data; |
|---|
| 60 | 67 | |
|---|
| 61 | 68 | struct hisi_thermal_sensor { |
|---|
| 69 | + struct hisi_thermal_data *data; |
|---|
| 62 | 70 | struct thermal_zone_device *tzd; |
|---|
| 71 | + const char *irq_name; |
|---|
| 63 | 72 | uint32_t id; |
|---|
| 64 | 73 | uint32_t thres_temp; |
|---|
| 65 | 74 | }; |
|---|
| 66 | 75 | |
|---|
| 76 | +struct hisi_thermal_ops { |
|---|
| 77 | + int (*get_temp)(struct hisi_thermal_sensor *sensor); |
|---|
| 78 | + int (*enable_sensor)(struct hisi_thermal_sensor *sensor); |
|---|
| 79 | + int (*disable_sensor)(struct hisi_thermal_sensor *sensor); |
|---|
| 80 | + int (*irq_handler)(struct hisi_thermal_sensor *sensor); |
|---|
| 81 | + int (*probe)(struct hisi_thermal_data *data); |
|---|
| 82 | +}; |
|---|
| 83 | + |
|---|
| 67 | 84 | struct hisi_thermal_data { |
|---|
| 68 | | - int (*get_temp)(struct hisi_thermal_data *data); |
|---|
| 69 | | - int (*enable_sensor)(struct hisi_thermal_data *data); |
|---|
| 70 | | - int (*disable_sensor)(struct hisi_thermal_data *data); |
|---|
| 71 | | - int (*irq_handler)(struct hisi_thermal_data *data); |
|---|
| 85 | + const struct hisi_thermal_ops *ops; |
|---|
| 86 | + struct hisi_thermal_sensor *sensor; |
|---|
| 72 | 87 | struct platform_device *pdev; |
|---|
| 73 | 88 | struct clk *clk; |
|---|
| 74 | | - struct hisi_thermal_sensor sensor; |
|---|
| 75 | 89 | void __iomem *regs; |
|---|
| 76 | | - int irq; |
|---|
| 90 | + int nr_sensors; |
|---|
| 77 | 91 | }; |
|---|
| 78 | 92 | |
|---|
| 79 | 93 | /* |
|---|
| .. | .. |
|---|
| 266 | 280 | (value << 4), addr + HI6220_TEMP0_CFG); |
|---|
| 267 | 281 | } |
|---|
| 268 | 282 | |
|---|
| 269 | | -static int hi6220_thermal_irq_handler(struct hisi_thermal_data *data) |
|---|
| 283 | +static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor) |
|---|
| 270 | 284 | { |
|---|
| 285 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 286 | + |
|---|
| 271 | 287 | hi6220_thermal_alarm_clear(data->regs, 1); |
|---|
| 272 | 288 | return 0; |
|---|
| 273 | 289 | } |
|---|
| 274 | 290 | |
|---|
| 275 | | -static int hi3660_thermal_irq_handler(struct hisi_thermal_data *data) |
|---|
| 291 | +static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor) |
|---|
| 276 | 292 | { |
|---|
| 277 | | - hi3660_thermal_alarm_clear(data->regs, data->sensor.id, 1); |
|---|
| 293 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 294 | + |
|---|
| 295 | + hi3660_thermal_alarm_clear(data->regs, sensor->id, 1); |
|---|
| 278 | 296 | return 0; |
|---|
| 279 | 297 | } |
|---|
| 280 | 298 | |
|---|
| 281 | | -static int hi6220_thermal_get_temp(struct hisi_thermal_data *data) |
|---|
| 299 | +static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor) |
|---|
| 282 | 300 | { |
|---|
| 301 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 302 | + |
|---|
| 283 | 303 | return hi6220_thermal_get_temperature(data->regs); |
|---|
| 284 | 304 | } |
|---|
| 285 | 305 | |
|---|
| 286 | | -static int hi3660_thermal_get_temp(struct hisi_thermal_data *data) |
|---|
| 306 | +static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor) |
|---|
| 287 | 307 | { |
|---|
| 288 | | - return hi3660_thermal_get_temperature(data->regs, data->sensor.id); |
|---|
| 308 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 309 | + |
|---|
| 310 | + return hi3660_thermal_get_temperature(data->regs, sensor->id); |
|---|
| 289 | 311 | } |
|---|
| 290 | 312 | |
|---|
| 291 | | -static int hi6220_thermal_disable_sensor(struct hisi_thermal_data *data) |
|---|
| 313 | +static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) |
|---|
| 292 | 314 | { |
|---|
| 315 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 316 | + |
|---|
| 293 | 317 | /* disable sensor module */ |
|---|
| 294 | 318 | hi6220_thermal_enable(data->regs, 0); |
|---|
| 295 | 319 | hi6220_thermal_alarm_enable(data->regs, 0); |
|---|
| .. | .. |
|---|
| 300 | 324 | return 0; |
|---|
| 301 | 325 | } |
|---|
| 302 | 326 | |
|---|
| 303 | | -static int hi3660_thermal_disable_sensor(struct hisi_thermal_data *data) |
|---|
| 327 | +static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) |
|---|
| 304 | 328 | { |
|---|
| 329 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 330 | + |
|---|
| 305 | 331 | /* disable sensor module */ |
|---|
| 306 | | - hi3660_thermal_alarm_enable(data->regs, data->sensor.id, 0); |
|---|
| 332 | + hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); |
|---|
| 307 | 333 | return 0; |
|---|
| 308 | 334 | } |
|---|
| 309 | 335 | |
|---|
| 310 | | -static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data) |
|---|
| 336 | +static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) |
|---|
| 311 | 337 | { |
|---|
| 312 | | - struct hisi_thermal_sensor *sensor = &data->sensor; |
|---|
| 338 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 313 | 339 | int ret; |
|---|
| 314 | 340 | |
|---|
| 315 | 341 | /* enable clock for tsensor */ |
|---|
| .. | .. |
|---|
| 345 | 371 | return 0; |
|---|
| 346 | 372 | } |
|---|
| 347 | 373 | |
|---|
| 348 | | -static int hi3660_thermal_enable_sensor(struct hisi_thermal_data *data) |
|---|
| 374 | +static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) |
|---|
| 349 | 375 | { |
|---|
| 350 | 376 | unsigned int value; |
|---|
| 351 | | - struct hisi_thermal_sensor *sensor = &data->sensor; |
|---|
| 377 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 352 | 378 | |
|---|
| 353 | 379 | /* disable interrupt */ |
|---|
| 354 | 380 | hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); |
|---|
| .. | .. |
|---|
| 371 | 397 | { |
|---|
| 372 | 398 | struct platform_device *pdev = data->pdev; |
|---|
| 373 | 399 | struct device *dev = &pdev->dev; |
|---|
| 374 | | - struct resource *res; |
|---|
| 375 | 400 | int ret; |
|---|
| 376 | | - |
|---|
| 377 | | - data->get_temp = hi6220_thermal_get_temp; |
|---|
| 378 | | - data->enable_sensor = hi6220_thermal_enable_sensor; |
|---|
| 379 | | - data->disable_sensor = hi6220_thermal_disable_sensor; |
|---|
| 380 | | - data->irq_handler = hi6220_thermal_irq_handler; |
|---|
| 381 | | - |
|---|
| 382 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 383 | | - data->regs = devm_ioremap_resource(dev, res); |
|---|
| 384 | | - if (IS_ERR(data->regs)) { |
|---|
| 385 | | - dev_err(dev, "failed to get io address\n"); |
|---|
| 386 | | - return PTR_ERR(data->regs); |
|---|
| 387 | | - } |
|---|
| 388 | 401 | |
|---|
| 389 | 402 | data->clk = devm_clk_get(dev, "thermal_clk"); |
|---|
| 390 | 403 | if (IS_ERR(data->clk)) { |
|---|
| .. | .. |
|---|
| 394 | 407 | return ret; |
|---|
| 395 | 408 | } |
|---|
| 396 | 409 | |
|---|
| 397 | | - data->irq = platform_get_irq(pdev, 0); |
|---|
| 398 | | - if (data->irq < 0) |
|---|
| 399 | | - return data->irq; |
|---|
| 410 | + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); |
|---|
| 411 | + if (!data->sensor) |
|---|
| 412 | + return -ENOMEM; |
|---|
| 400 | 413 | |
|---|
| 401 | | - data->sensor.id = HI6220_DEFAULT_SENSOR; |
|---|
| 414 | + data->sensor[0].id = HI6220_CLUSTER0_SENSOR; |
|---|
| 415 | + data->sensor[0].irq_name = "tsensor_intr"; |
|---|
| 416 | + data->sensor[0].data = data; |
|---|
| 417 | + data->nr_sensors = 1; |
|---|
| 402 | 418 | |
|---|
| 403 | 419 | return 0; |
|---|
| 404 | 420 | } |
|---|
| .. | .. |
|---|
| 407 | 423 | { |
|---|
| 408 | 424 | struct platform_device *pdev = data->pdev; |
|---|
| 409 | 425 | struct device *dev = &pdev->dev; |
|---|
| 410 | | - struct resource *res; |
|---|
| 411 | 426 | |
|---|
| 412 | | - data->get_temp = hi3660_thermal_get_temp; |
|---|
| 413 | | - data->enable_sensor = hi3660_thermal_enable_sensor; |
|---|
| 414 | | - data->disable_sensor = hi3660_thermal_disable_sensor; |
|---|
| 415 | | - data->irq_handler = hi3660_thermal_irq_handler; |
|---|
| 427 | + data->nr_sensors = 1; |
|---|
| 416 | 428 | |
|---|
| 417 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 418 | | - data->regs = devm_ioremap_resource(dev, res); |
|---|
| 419 | | - if (IS_ERR(data->regs)) { |
|---|
| 420 | | - dev_err(dev, "failed to get io address\n"); |
|---|
| 421 | | - return PTR_ERR(data->regs); |
|---|
| 422 | | - } |
|---|
| 429 | + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) * |
|---|
| 430 | + data->nr_sensors, GFP_KERNEL); |
|---|
| 431 | + if (!data->sensor) |
|---|
| 432 | + return -ENOMEM; |
|---|
| 423 | 433 | |
|---|
| 424 | | - data->irq = platform_get_irq(pdev, 0); |
|---|
| 425 | | - if (data->irq < 0) |
|---|
| 426 | | - return data->irq; |
|---|
| 427 | | - |
|---|
| 428 | | - data->sensor.id = HI3660_DEFAULT_SENSOR; |
|---|
| 434 | + data->sensor[0].id = HI3660_BIG_SENSOR; |
|---|
| 435 | + data->sensor[0].irq_name = "tsensor_a73"; |
|---|
| 436 | + data->sensor[0].data = data; |
|---|
| 429 | 437 | |
|---|
| 430 | 438 | return 0; |
|---|
| 431 | 439 | } |
|---|
| 432 | 440 | |
|---|
| 433 | 441 | static int hisi_thermal_get_temp(void *__data, int *temp) |
|---|
| 434 | 442 | { |
|---|
| 435 | | - struct hisi_thermal_data *data = __data; |
|---|
| 436 | | - struct hisi_thermal_sensor *sensor = &data->sensor; |
|---|
| 443 | + struct hisi_thermal_sensor *sensor = __data; |
|---|
| 444 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 437 | 445 | |
|---|
| 438 | | - *temp = data->get_temp(data); |
|---|
| 446 | + *temp = data->ops->get_temp(sensor); |
|---|
| 439 | 447 | |
|---|
| 440 | | - dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", |
|---|
| 441 | | - sensor->id, *temp, sensor->thres_temp); |
|---|
| 448 | + dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n", |
|---|
| 449 | + sensor->tzd, sensor->id, *temp, sensor->thres_temp); |
|---|
| 442 | 450 | |
|---|
| 443 | 451 | return 0; |
|---|
| 444 | 452 | } |
|---|
| .. | .. |
|---|
| 449 | 457 | |
|---|
| 450 | 458 | static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) |
|---|
| 451 | 459 | { |
|---|
| 452 | | - struct hisi_thermal_data *data = dev; |
|---|
| 453 | | - struct hisi_thermal_sensor *sensor = &data->sensor; |
|---|
| 460 | + struct hisi_thermal_sensor *sensor = dev; |
|---|
| 461 | + struct hisi_thermal_data *data = sensor->data; |
|---|
| 454 | 462 | int temp = 0; |
|---|
| 455 | 463 | |
|---|
| 456 | | - data->irq_handler(data); |
|---|
| 464 | + data->ops->irq_handler(sensor); |
|---|
| 457 | 465 | |
|---|
| 458 | | - hisi_thermal_get_temp(data, &temp); |
|---|
| 466 | + hisi_thermal_get_temp(sensor, &temp); |
|---|
| 459 | 467 | |
|---|
| 460 | 468 | if (temp >= sensor->thres_temp) { |
|---|
| 461 | | - dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", |
|---|
| 462 | | - temp, sensor->thres_temp); |
|---|
| 469 | + dev_crit(&data->pdev->dev, |
|---|
| 470 | + "sensor <%d> THERMAL ALARM: %d > %d\n", |
|---|
| 471 | + sensor->id, temp, sensor->thres_temp); |
|---|
| 463 | 472 | |
|---|
| 464 | | - thermal_zone_device_update(data->sensor.tzd, |
|---|
| 473 | + thermal_zone_device_update(sensor->tzd, |
|---|
| 465 | 474 | THERMAL_EVENT_UNSPECIFIED); |
|---|
| 466 | 475 | |
|---|
| 467 | 476 | } else { |
|---|
| 468 | | - dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", |
|---|
| 469 | | - temp, sensor->thres_temp); |
|---|
| 477 | + dev_crit(&data->pdev->dev, |
|---|
| 478 | + "sensor <%d> THERMAL ALARM stopped: %d < %d\n", |
|---|
| 479 | + sensor->id, temp, sensor->thres_temp); |
|---|
| 470 | 480 | } |
|---|
| 471 | 481 | |
|---|
| 472 | 482 | return IRQ_HANDLED; |
|---|
| 473 | 483 | } |
|---|
| 474 | 484 | |
|---|
| 475 | 485 | static int hisi_thermal_register_sensor(struct platform_device *pdev, |
|---|
| 476 | | - struct hisi_thermal_data *data, |
|---|
| 477 | 486 | struct hisi_thermal_sensor *sensor) |
|---|
| 478 | 487 | { |
|---|
| 479 | 488 | int ret, i; |
|---|
| 480 | 489 | const struct thermal_trip *trip; |
|---|
| 481 | 490 | |
|---|
| 482 | 491 | sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, |
|---|
| 483 | | - sensor->id, data, |
|---|
| 492 | + sensor->id, sensor, |
|---|
| 484 | 493 | &hisi_of_thermal_ops); |
|---|
| 485 | 494 | if (IS_ERR(sensor->tzd)) { |
|---|
| 486 | 495 | ret = PTR_ERR(sensor->tzd); |
|---|
| .. | .. |
|---|
| 502 | 511 | return 0; |
|---|
| 503 | 512 | } |
|---|
| 504 | 513 | |
|---|
| 514 | +static const struct hisi_thermal_ops hi6220_ops = { |
|---|
| 515 | + .get_temp = hi6220_thermal_get_temp, |
|---|
| 516 | + .enable_sensor = hi6220_thermal_enable_sensor, |
|---|
| 517 | + .disable_sensor = hi6220_thermal_disable_sensor, |
|---|
| 518 | + .irq_handler = hi6220_thermal_irq_handler, |
|---|
| 519 | + .probe = hi6220_thermal_probe, |
|---|
| 520 | +}; |
|---|
| 521 | + |
|---|
| 522 | +static const struct hisi_thermal_ops hi3660_ops = { |
|---|
| 523 | + .get_temp = hi3660_thermal_get_temp, |
|---|
| 524 | + .enable_sensor = hi3660_thermal_enable_sensor, |
|---|
| 525 | + .disable_sensor = hi3660_thermal_disable_sensor, |
|---|
| 526 | + .irq_handler = hi3660_thermal_irq_handler, |
|---|
| 527 | + .probe = hi3660_thermal_probe, |
|---|
| 528 | +}; |
|---|
| 529 | + |
|---|
| 505 | 530 | static const struct of_device_id of_hisi_thermal_match[] = { |
|---|
| 506 | 531 | { |
|---|
| 507 | 532 | .compatible = "hisilicon,tsensor", |
|---|
| 508 | | - .data = hi6220_thermal_probe |
|---|
| 533 | + .data = &hi6220_ops, |
|---|
| 509 | 534 | }, |
|---|
| 510 | 535 | { |
|---|
| 511 | 536 | .compatible = "hisilicon,hi3660-tsensor", |
|---|
| 512 | | - .data = hi3660_thermal_probe |
|---|
| 537 | + .data = &hi3660_ops, |
|---|
| 513 | 538 | }, |
|---|
| 514 | 539 | { /* end */ } |
|---|
| 515 | 540 | }; |
|---|
| .. | .. |
|---|
| 520 | 545 | { |
|---|
| 521 | 546 | struct thermal_zone_device *tzd = sensor->tzd; |
|---|
| 522 | 547 | |
|---|
| 523 | | - tzd->ops->set_mode(tzd, |
|---|
| 524 | | - on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); |
|---|
| 548 | + if (on) |
|---|
| 549 | + thermal_zone_device_enable(tzd); |
|---|
| 550 | + else |
|---|
| 551 | + thermal_zone_device_disable(tzd); |
|---|
| 525 | 552 | } |
|---|
| 526 | 553 | |
|---|
| 527 | 554 | static int hisi_thermal_probe(struct platform_device *pdev) |
|---|
| 528 | 555 | { |
|---|
| 529 | 556 | struct hisi_thermal_data *data; |
|---|
| 530 | | - int (*platform_probe)(struct hisi_thermal_data *); |
|---|
| 531 | 557 | struct device *dev = &pdev->dev; |
|---|
| 532 | | - int ret; |
|---|
| 558 | + struct resource *res; |
|---|
| 559 | + int i, ret; |
|---|
| 533 | 560 | |
|---|
| 534 | 561 | data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); |
|---|
| 535 | 562 | if (!data) |
|---|
| .. | .. |
|---|
| 537 | 564 | |
|---|
| 538 | 565 | data->pdev = pdev; |
|---|
| 539 | 566 | platform_set_drvdata(pdev, data); |
|---|
| 567 | + data->ops = of_device_get_match_data(dev); |
|---|
| 540 | 568 | |
|---|
| 541 | | - platform_probe = of_device_get_match_data(dev); |
|---|
| 542 | | - if (!platform_probe) { |
|---|
| 543 | | - dev_err(dev, "failed to get probe func\n"); |
|---|
| 544 | | - return -EINVAL; |
|---|
| 569 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 570 | + data->regs = devm_ioremap_resource(dev, res); |
|---|
| 571 | + if (IS_ERR(data->regs)) { |
|---|
| 572 | + dev_err(dev, "failed to get io address\n"); |
|---|
| 573 | + return PTR_ERR(data->regs); |
|---|
| 545 | 574 | } |
|---|
| 546 | 575 | |
|---|
| 547 | | - ret = platform_probe(data); |
|---|
| 576 | + ret = data->ops->probe(data); |
|---|
| 548 | 577 | if (ret) |
|---|
| 549 | 578 | return ret; |
|---|
| 550 | 579 | |
|---|
| 551 | | - ret = hisi_thermal_register_sensor(pdev, data, |
|---|
| 552 | | - &data->sensor); |
|---|
| 553 | | - if (ret) { |
|---|
| 554 | | - dev_err(dev, "failed to register thermal sensor: %d\n", ret); |
|---|
| 555 | | - return ret; |
|---|
| 556 | | - } |
|---|
| 580 | + for (i = 0; i < data->nr_sensors; i++) { |
|---|
| 581 | + struct hisi_thermal_sensor *sensor = &data->sensor[i]; |
|---|
| 557 | 582 | |
|---|
| 558 | | - ret = data->enable_sensor(data); |
|---|
| 559 | | - if (ret) { |
|---|
| 560 | | - dev_err(dev, "Failed to setup the sensor: %d\n", ret); |
|---|
| 561 | | - return ret; |
|---|
| 562 | | - } |
|---|
| 563 | | - |
|---|
| 564 | | - if (data->irq) { |
|---|
| 565 | | - ret = devm_request_threaded_irq(dev, data->irq, NULL, |
|---|
| 566 | | - hisi_thermal_alarm_irq_thread, |
|---|
| 567 | | - IRQF_ONESHOT, "hisi_thermal", data); |
|---|
| 568 | | - if (ret < 0) { |
|---|
| 569 | | - dev_err(dev, "failed to request alarm irq: %d\n", ret); |
|---|
| 583 | + ret = hisi_thermal_register_sensor(pdev, sensor); |
|---|
| 584 | + if (ret) { |
|---|
| 585 | + dev_err(dev, "failed to register thermal sensor: %d\n", |
|---|
| 586 | + ret); |
|---|
| 570 | 587 | return ret; |
|---|
| 571 | 588 | } |
|---|
| 572 | | - } |
|---|
| 573 | 589 | |
|---|
| 574 | | - hisi_thermal_toggle_sensor(&data->sensor, true); |
|---|
| 590 | + ret = platform_get_irq(pdev, 0); |
|---|
| 591 | + if (ret < 0) |
|---|
| 592 | + return ret; |
|---|
| 593 | + |
|---|
| 594 | + ret = devm_request_threaded_irq(dev, ret, NULL, |
|---|
| 595 | + hisi_thermal_alarm_irq_thread, |
|---|
| 596 | + IRQF_ONESHOT, sensor->irq_name, |
|---|
| 597 | + sensor); |
|---|
| 598 | + if (ret < 0) { |
|---|
| 599 | + dev_err(dev, "Failed to request alarm irq: %d\n", ret); |
|---|
| 600 | + return ret; |
|---|
| 601 | + } |
|---|
| 602 | + |
|---|
| 603 | + ret = data->ops->enable_sensor(sensor); |
|---|
| 604 | + if (ret) { |
|---|
| 605 | + dev_err(dev, "Failed to setup the sensor: %d\n", ret); |
|---|
| 606 | + return ret; |
|---|
| 607 | + } |
|---|
| 608 | + |
|---|
| 609 | + hisi_thermal_toggle_sensor(sensor, true); |
|---|
| 610 | + } |
|---|
| 575 | 611 | |
|---|
| 576 | 612 | return 0; |
|---|
| 577 | 613 | } |
|---|
| .. | .. |
|---|
| 579 | 615 | static int hisi_thermal_remove(struct platform_device *pdev) |
|---|
| 580 | 616 | { |
|---|
| 581 | 617 | struct hisi_thermal_data *data = platform_get_drvdata(pdev); |
|---|
| 582 | | - struct hisi_thermal_sensor *sensor = &data->sensor; |
|---|
| 618 | + int i; |
|---|
| 583 | 619 | |
|---|
| 584 | | - hisi_thermal_toggle_sensor(sensor, false); |
|---|
| 620 | + for (i = 0; i < data->nr_sensors; i++) { |
|---|
| 621 | + struct hisi_thermal_sensor *sensor = &data->sensor[i]; |
|---|
| 585 | 622 | |
|---|
| 586 | | - data->disable_sensor(data); |
|---|
| 623 | + hisi_thermal_toggle_sensor(sensor, false); |
|---|
| 624 | + data->ops->disable_sensor(sensor); |
|---|
| 625 | + } |
|---|
| 587 | 626 | |
|---|
| 588 | 627 | return 0; |
|---|
| 589 | 628 | } |
|---|
| .. | .. |
|---|
| 592 | 631 | static int hisi_thermal_suspend(struct device *dev) |
|---|
| 593 | 632 | { |
|---|
| 594 | 633 | struct hisi_thermal_data *data = dev_get_drvdata(dev); |
|---|
| 634 | + int i; |
|---|
| 595 | 635 | |
|---|
| 596 | | - data->disable_sensor(data); |
|---|
| 636 | + for (i = 0; i < data->nr_sensors; i++) |
|---|
| 637 | + data->ops->disable_sensor(&data->sensor[i]); |
|---|
| 597 | 638 | |
|---|
| 598 | 639 | return 0; |
|---|
| 599 | 640 | } |
|---|
| .. | .. |
|---|
| 601 | 642 | static int hisi_thermal_resume(struct device *dev) |
|---|
| 602 | 643 | { |
|---|
| 603 | 644 | struct hisi_thermal_data *data = dev_get_drvdata(dev); |
|---|
| 645 | + int i, ret = 0; |
|---|
| 604 | 646 | |
|---|
| 605 | | - return data->enable_sensor(data); |
|---|
| 647 | + for (i = 0; i < data->nr_sensors; i++) |
|---|
| 648 | + ret |= data->ops->enable_sensor(&data->sensor[i]); |
|---|
| 649 | + |
|---|
| 650 | + return ret; |
|---|
| 606 | 651 | } |
|---|
| 607 | 652 | #endif |
|---|
| 608 | 653 | |
|---|