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

drm/nouveau: just pass gpio line to pwm_*, not entire gpio struct

We don't need more than the line id to determine the PWM controller, and
the GPIO interfaces are about to change somewhat.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

+25 -30
+2 -2
drivers/gpu/drm/nouveau/nouveau_drv.h
··· 556 556 557 557 int (*voltage_get)(struct drm_device *); 558 558 int (*voltage_set)(struct drm_device *, int voltage); 559 - int (*pwm_get)(struct drm_device *, struct dcb_gpio_entry*, u32*, u32*); 560 - int (*pwm_set)(struct drm_device *, struct dcb_gpio_entry*, u32, u32); 559 + int (*pwm_get)(struct drm_device *, int line, u32*, u32*); 560 + int (*pwm_set)(struct drm_device *, int line, u32, u32); 561 561 int (*temp_get)(struct drm_device *); 562 562 }; 563 563
+2 -2
drivers/gpu/drm/nouveau/nouveau_pm.c
··· 49 49 50 50 gpio = nouveau_bios_gpio_entry(dev, DCB_GPIO_PWM_FAN); 51 51 if (gpio) { 52 - ret = pm->pwm_get(dev, gpio, &divs, &duty); 52 + ret = pm->pwm_get(dev, gpio->line, &divs, &duty); 53 53 if (ret == 0) { 54 54 divs = max(divs, duty); 55 55 if (dev_priv->card_type <= NV_40 || ··· 90 90 (gpio->state[0] & 1)) 91 91 duty = divs - duty; 92 92 93 - return pm->pwm_set(dev, gpio, divs, duty); 93 + return pm->pwm_set(dev, gpio->line, divs, duty); 94 94 } 95 95 96 96 return -ENODEV;
+4 -4
drivers/gpu/drm/nouveau/nouveau_pm.h
··· 55 55 int nv40_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *); 56 56 void *nv40_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *); 57 57 int nv40_pm_clocks_set(struct drm_device *, void *); 58 - int nv40_pm_pwm_get(struct drm_device *, struct dcb_gpio_entry *, u32*, u32*); 59 - int nv40_pm_pwm_set(struct drm_device *, struct dcb_gpio_entry *, u32, u32); 58 + int nv40_pm_pwm_get(struct drm_device *, int, u32 *, u32 *); 59 + int nv40_pm_pwm_set(struct drm_device *, int, u32, u32); 60 60 61 61 /* nv50_pm.c */ 62 62 int nv50_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *); 63 63 void *nv50_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *); 64 64 int nv50_pm_clocks_set(struct drm_device *, void *); 65 - int nv50_pm_pwm_get(struct drm_device *, struct dcb_gpio_entry *, u32*, u32*); 66 - int nv50_pm_pwm_set(struct drm_device *, struct dcb_gpio_entry *, u32, u32); 65 + int nv50_pm_pwm_get(struct drm_device *, int, u32 *, u32 *); 66 + int nv50_pm_pwm_set(struct drm_device *, int, u32, u32); 67 67 68 68 /* nva3_pm.c */ 69 69 int nva3_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
+8 -10
drivers/gpu/drm/nouveau/nv40_pm.c
··· 351 351 } 352 352 353 353 int 354 - nv40_pm_pwm_get(struct drm_device *dev, struct dcb_gpio_entry *gpio, 355 - u32 *divs, u32 *duty) 354 + nv40_pm_pwm_get(struct drm_device *dev, int line, u32 *divs, u32 *duty) 356 355 { 357 - if (gpio->line == 2) { 356 + if (line == 2) { 358 357 u32 reg = nv_rd32(dev, 0x0010f0); 359 358 if (reg & 0x80000000) { 360 359 *duty = (reg & 0x7fff0000) >> 16; ··· 361 362 return 0; 362 363 } 363 364 } else 364 - if (gpio->line == 9) { 365 + if (line == 9) { 365 366 u32 reg = nv_rd32(dev, 0x0015f4); 366 367 if (reg & 0x80000000) { 367 368 *divs = nv_rd32(dev, 0x0015f8); ··· 369 370 return 0; 370 371 } 371 372 } else { 372 - NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line); 373 + NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", line); 373 374 return -ENODEV; 374 375 } 375 376 ··· 377 378 } 378 379 379 380 int 380 - nv40_pm_pwm_set(struct drm_device *dev, struct dcb_gpio_entry *gpio, 381 - u32 divs, u32 duty) 381 + nv40_pm_pwm_set(struct drm_device *dev, int line, u32 divs, u32 duty) 382 382 { 383 - if (gpio->line == 2) { 383 + if (line == 2) { 384 384 nv_wr32(dev, 0x0010f0, 0x80000000 | (duty << 16) | divs); 385 385 } else 386 - if (gpio->line == 9) { 386 + if (line == 9) { 387 387 nv_wr32(dev, 0x0015f8, divs); 388 388 nv_wr32(dev, 0x0015f4, duty | 0x80000000); 389 389 } else { 390 - NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line); 390 + NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", line); 391 391 return -ENODEV; 392 392 } 393 393
+9 -12
drivers/gpu/drm/nouveau/nv50_pm.c
··· 715 715 } 716 716 717 717 static int 718 - pwm_info(struct drm_device *dev, struct dcb_gpio_entry *gpio, 719 - int *ctrl, int *line, int *indx) 718 + pwm_info(struct drm_device *dev, int *line, int *ctrl, int *indx) 720 719 { 721 - if (gpio->line == 0x04) { 720 + if (*line == 0x04) { 722 721 *ctrl = 0x00e100; 723 722 *line = 4; 724 723 *indx = 0; 725 724 } else 726 - if (gpio->line == 0x09) { 725 + if (*line == 0x09) { 727 726 *ctrl = 0x00e100; 728 727 *line = 9; 729 728 *indx = 1; 730 729 } else 731 - if (gpio->line == 0x10) { 730 + if (*line == 0x10) { 732 731 *ctrl = 0x00e28c; 733 732 *line = 0; 734 733 *indx = 0; 735 734 } else { 736 - NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line); 735 + NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", *line); 737 736 return -ENODEV; 738 737 } 739 738 ··· 740 741 } 741 742 742 743 int 743 - nv50_pm_pwm_get(struct drm_device *dev, struct dcb_gpio_entry *gpio, 744 - u32 *divs, u32 *duty) 744 + nv50_pm_pwm_get(struct drm_device *dev, int line, u32 *divs, u32 *duty) 745 745 { 746 - int ctrl, line, id, ret = pwm_info(dev, gpio, &ctrl, &line, &id); 746 + int ctrl, id, ret = pwm_info(dev, &line, &ctrl, &id); 747 747 if (ret) 748 748 return ret; 749 749 ··· 756 758 } 757 759 758 760 int 759 - nv50_pm_pwm_set(struct drm_device *dev, struct dcb_gpio_entry *gpio, 760 - u32 divs, u32 duty) 761 + nv50_pm_pwm_set(struct drm_device *dev, int line, u32 divs, u32 duty) 761 762 { 762 - int ctrl, line, id, ret = pwm_info(dev, gpio, &ctrl, &line, &id); 763 + int ctrl, id, ret = pwm_info(dev, &line, &ctrl, &id); 763 764 if (ret) 764 765 return ret; 765 766