Skip to content

add bcm2835-pwm to bcm2708.c #756

Closed
Closed
@btanghe

Description

@btanghe

In linux kernel release 3.19-rc1, a bcm2835-pwm driver is added.
To load the driver properly with board files (bcm2708.c), this patch has to be added to the file

diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
index 6349cbe..2f05901 100644
--- a/arch/arm/mach-bcm2708/bcm2708.c
+++ b/arch/arm/mach-bcm2708/bcm2708.c
@@ -226,6 +226,10 @@ static struct clk sdhost_clk = {
 #endif
 };

+static struct clk pwm_clk = {
+        .rate = 9200000,
+};
+
 static struct clk_lookup lookups[] = {
    {           /* UART0 */
     .dev_id = "dev:f1",
@@ -243,6 +247,10 @@ static struct clk_lookup lookups[] = {
     }, {   /* BSC1 */
         .dev_id = "bcm2708_i2c.1",
         .clk = &sdhost_clk,
+    },
+   {
+    .dev_id = "bcm2835-pwm.1",
+    .clk = &pwm_clk,
     }
 };

@@ -632,6 +640,21 @@ static struct platform_device bcm2708_bsc0_device = {
    .resource = bcm2708_bsc0_resources,
 };

+static struct resource bcm2835_pwm_resources[] = {
+   {
+    .start = PWM_BASE,
+    .end = PWM_BASE + SZ_4K - 1,
+    .flags = IORESOURCE_MEM,
+    }
+};
+
+static struct platform_device pwm_bcm2835_device = {
+   .name = "bcm2835-pwm",
+   .id = 1,
+   .resource = bcm2835_pwm_resources,
+   .num_resources = ARRAY_SIZE(bcm2835_pwm_resources),
+};
+

 static struct resource bcm2708_bsc1_resources[] = {
    {
@@ -957,6 +980,8 @@ void __init bcm2708_init(void)
    spi_register_board_info(bcm2708_spi_devices,
            ARRAY_SIZE(bcm2708_spi_devices));
 #endif
+
+   bcm_register_device(&pwm_bcm2835_device);
 }

 static void timer_set_mode(enum clock_event_mode mode,
diff --git a/arch/arm/mach-bcm2708/include/mach/platform.h b/arch/arm/mach-bcm2708/include/mach/platform.h
index 2e7e1bb..d3975cf 100644
--- a/arch/arm/mach-bcm2708/include/mach/platform.h
+++ b/arch/arm/mach-bcm2708/include/mach/platform.h
@@ -76,6 +76,7 @@
 #define BSC1_BASE       (BCM2708_PERI_BASE + 0x804000) /* BSC1 I2C/TWI */
 #define USB_BASE                 (BCM2708_PERI_BASE + 0x980000) /* DTC_OTG USB controller */
 #define MCORE_BASE               (BCM2708_PERI_BASE + 0x0000)   /* Fake frame buffer device (actually the multicore sync block*/
+#define PWM_BASE        (BCM2708_PERI_BASE + 0x20C000)

 #define ARMCTRL_BASE             (ARM_BASE + 0x000)
 #define ARMCTRL_IC_BASE          (ARM_BASE + 0x200)           /* ARM interrupt controller */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions