Skip to content

Commit

Permalink
drm/nouveau: just pass gpio line to pwm_*, not entire gpio struct
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Ben Skeggs committed Dec 21, 2011
1 parent c8b9641 commit 675aac0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ struct nouveau_pm_engine {

int (*voltage_get)(struct drm_device *);
int (*voltage_set)(struct drm_device *, int voltage);
int (*pwm_get)(struct drm_device *, struct dcb_gpio_entry*, u32*, u32*);
int (*pwm_set)(struct drm_device *, struct dcb_gpio_entry*, u32, u32);
int (*pwm_get)(struct drm_device *, int line, u32*, u32*);
int (*pwm_set)(struct drm_device *, int line, u32, u32);
int (*temp_get)(struct drm_device *);
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ nouveau_pwmfan_get(struct drm_device *dev)

gpio = nouveau_bios_gpio_entry(dev, DCB_GPIO_PWM_FAN);
if (gpio) {
ret = pm->pwm_get(dev, gpio, &divs, &duty);
ret = pm->pwm_get(dev, gpio->line, &divs, &duty);
if (ret == 0) {
divs = max(divs, duty);
if (dev_priv->card_type <= NV_40 ||
Expand Down Expand Up @@ -90,7 +90,7 @@ nouveau_pwmfan_set(struct drm_device *dev, int percent)
(gpio->state[0] & 1))
duty = divs - duty;

return pm->pwm_set(dev, gpio, divs, duty);
return pm->pwm_set(dev, gpio->line, divs, duty);
}

return -ENODEV;
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/nouveau/nouveau_pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ int nv04_pm_clocks_set(struct drm_device *, void *);
int nv40_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
void *nv40_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
int nv40_pm_clocks_set(struct drm_device *, void *);
int nv40_pm_pwm_get(struct drm_device *, struct dcb_gpio_entry *, u32*, u32*);
int nv40_pm_pwm_set(struct drm_device *, struct dcb_gpio_entry *, u32, u32);
int nv40_pm_pwm_get(struct drm_device *, int, u32 *, u32 *);
int nv40_pm_pwm_set(struct drm_device *, int, u32, u32);

/* nv50_pm.c */
int nv50_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
void *nv50_pm_clocks_pre(struct drm_device *, struct nouveau_pm_level *);
int nv50_pm_clocks_set(struct drm_device *, void *);
int nv50_pm_pwm_get(struct drm_device *, struct dcb_gpio_entry *, u32*, u32*);
int nv50_pm_pwm_set(struct drm_device *, struct dcb_gpio_entry *, u32, u32);
int nv50_pm_pwm_get(struct drm_device *, int, u32 *, u32 *);
int nv50_pm_pwm_set(struct drm_device *, int, u32, u32);

/* nva3_pm.c */
int nva3_pm_clocks_get(struct drm_device *, struct nouveau_pm_level *);
Expand Down
18 changes: 8 additions & 10 deletions drivers/gpu/drm/nouveau/nv40_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,44 +351,42 @@ nv40_pm_clocks_set(struct drm_device *dev, void *pre_state)
}

int
nv40_pm_pwm_get(struct drm_device *dev, struct dcb_gpio_entry *gpio,
u32 *divs, u32 *duty)
nv40_pm_pwm_get(struct drm_device *dev, int line, u32 *divs, u32 *duty)
{
if (gpio->line == 2) {
if (line == 2) {
u32 reg = nv_rd32(dev, 0x0010f0);
if (reg & 0x80000000) {
*duty = (reg & 0x7fff0000) >> 16;
*divs = (reg & 0x00007fff);
return 0;
}
} else
if (gpio->line == 9) {
if (line == 9) {
u32 reg = nv_rd32(dev, 0x0015f4);
if (reg & 0x80000000) {
*divs = nv_rd32(dev, 0x0015f8);
*duty = (reg & 0x7fffffff);
return 0;
}
} else {
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line);
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", line);
return -ENODEV;
}

return -EINVAL;
}

int
nv40_pm_pwm_set(struct drm_device *dev, struct dcb_gpio_entry *gpio,
u32 divs, u32 duty)
nv40_pm_pwm_set(struct drm_device *dev, int line, u32 divs, u32 duty)
{
if (gpio->line == 2) {
if (line == 2) {
nv_wr32(dev, 0x0010f0, 0x80000000 | (duty << 16) | divs);
} else
if (gpio->line == 9) {
if (line == 9) {
nv_wr32(dev, 0x0015f8, divs);
nv_wr32(dev, 0x0015f4, duty | 0x80000000);
} else {
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line);
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", line);
return -ENODEV;
}

Expand Down
21 changes: 9 additions & 12 deletions drivers/gpu/drm/nouveau/nv50_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,36 +715,34 @@ nv50_pm_clocks_set(struct drm_device *dev, void *data)
}

static int
pwm_info(struct drm_device *dev, struct dcb_gpio_entry *gpio,
int *ctrl, int *line, int *indx)
pwm_info(struct drm_device *dev, int *line, int *ctrl, int *indx)
{
if (gpio->line == 0x04) {
if (*line == 0x04) {
*ctrl = 0x00e100;
*line = 4;
*indx = 0;
} else
if (gpio->line == 0x09) {
if (*line == 0x09) {
*ctrl = 0x00e100;
*line = 9;
*indx = 1;
} else
if (gpio->line == 0x10) {
if (*line == 0x10) {
*ctrl = 0x00e28c;
*line = 0;
*indx = 0;
} else {
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", gpio->line);
NV_ERROR(dev, "unknown pwm ctrl for gpio %d\n", *line);
return -ENODEV;
}

return 0;
}

int
nv50_pm_pwm_get(struct drm_device *dev, struct dcb_gpio_entry *gpio,
u32 *divs, u32 *duty)
nv50_pm_pwm_get(struct drm_device *dev, int line, u32 *divs, u32 *duty)
{
int ctrl, line, id, ret = pwm_info(dev, gpio, &ctrl, &line, &id);
int ctrl, id, ret = pwm_info(dev, &line, &ctrl, &id);
if (ret)
return ret;

Expand All @@ -758,10 +756,9 @@ nv50_pm_pwm_get(struct drm_device *dev, struct dcb_gpio_entry *gpio,
}

int
nv50_pm_pwm_set(struct drm_device *dev, struct dcb_gpio_entry *gpio,
u32 divs, u32 duty)
nv50_pm_pwm_set(struct drm_device *dev, int line, u32 divs, u32 duty)
{
int ctrl, line, id, ret = pwm_info(dev, gpio, &ctrl, &line, &id);
int ctrl, id, ret = pwm_info(dev, &line, &ctrl, &id);
if (ret)
return ret;

Expand Down

0 comments on commit 675aac0

Please sign in to comment.