Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333101
b: refs/heads/master
c: d1b6886
h: refs/heads/master
i:
  333099: 4aa6e81
v: v3
  • Loading branch information
Thierry Reding committed Oct 5, 2012
1 parent 68329f1 commit 3935052
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60ce70285b4d3b933eea15e494a9b35fe85b19b7
refs/heads/master: d1b6886502160eb771aefe21c1f891597138ddfe
18 changes: 8 additions & 10 deletions trunk/arch/unicore32/include/mach/regs-ost.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@
* Interrupt Enable Reg OST_OIER
*/
#define OST_OIER (PKUNITY_OST_BASE + 0x001C)

/*
* PWM Pulse Width Control Reg OST_PWMPWCR
*/
#define OST_PWMPWCR (PKUNITY_OST_BASE + 0x0080)
/*
* PWM Duty Cycle Control Reg OST_PWMDCCR
*/
#define OST_PWMDCCR (PKUNITY_OST_BASE + 0x0084)
/*
* PWM Period Control Reg OST_PWMPCR
* PWM Registers: IO base address: PKUNITY_OST_BASE + 0x80
* PWCR: Pulse Width Control Reg
* DCCR: Duty Cycle Control Reg
* PCR: Period Control Reg
*/
#define OST_PWMPCR (PKUNITY_OST_BASE + 0x0088)
#define OST_PWM_PWCR (0x00)
#define OST_PWM_DCCR (0x04)
#define OST_PWM_PCR (0x08)

/*
* Match detected 0 OST_OSSR_M0
Expand Down
21 changes: 18 additions & 3 deletions trunk/arch/unicore32/kernel/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct pwm_device {
struct list_head node;
struct platform_device *pdev;

void __iomem *base;

const char *label;
struct clk *clk;
int clk_enabled;
Expand Down Expand Up @@ -69,9 +71,11 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
* before writing to the registers
*/
clk_enable(pwm->clk);
OST_PWMPWCR = prescale;
OST_PWMDCCR = pv - dc;
OST_PWMPCR = pv;

writel(prescale, pwm->base + OST_PWM_PWCR);
writel(pv - dc, pwm->base + OST_PWM_DCCR);
writel(pv, pwm->base + OST_PWM_PCR);

clk_disable(pwm->clk);

return 0;
Expand Down Expand Up @@ -190,10 +194,19 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
goto err_free_clk;
}

pwm->base = ioremap_nocache(r->start, resource_size(r));
if (pwm->base == NULL) {
dev_err(&pdev->dev, "failed to remap memory resource\n");
ret = -EADDRNOTAVAIL;
goto err_release_mem;
}

__add_pwm(pwm);
platform_set_drvdata(pdev, pwm);
return pwm;

err_release_mem:
release_mem_region(r->start, resource_size(r));
err_free_clk:
clk_put(pwm->clk);
err_free:
Expand Down Expand Up @@ -224,6 +237,8 @@ static int __devexit pwm_remove(struct platform_device *pdev)
list_del(&pwm->node);
mutex_unlock(&pwm_lock);

iounmap(pwm->base);

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(r->start, resource_size(r));

Expand Down

0 comments on commit 3935052

Please sign in to comment.