commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=96d9cee84d754866563c869319f7e44540ce3f41
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Steven Miao <[email protected]>
Signed-off-by: Bob Liu <[email protected]>
---
 Documentation/blackfin/gptimers-example.c |   53 ++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/Documentation/blackfin/gptimers-example.c b/Documentation/blackfin/gptimers-example.c
index b1bd634..b6a0c8b 100644
--- a/Documentation/blackfin/gptimers-example.c
+++ b/Documentation/blackfin/gptimers-example.c
@@ -17,6 +17,11 @@
 
 #define DRIVER_NAME "gptimer_example"
 
+#define TEST_TMR_PIN P_TMR0
+#define TEST_TMR_IRQ IRQ_TIMER0
+#define TEST_TMR_ID TIMER0_id
+#define TEST_TMR_BIT TIMER0bit
+
 struct gptimer_data {
 	uint32_t period, width;
 };
@@ -29,15 +34,15 @@ static irqreturn_t gptimer_example_irq(int irq, void *dev_id)
 	struct gptimer_data *data = ""
 
 	/* make sure it was our timer which caused the interrupt */
-	if (!get_gptimer_intr(TIMER5_id))
+	if (!get_gptimer_intr(TEST_TMR_ID))
 		return IRQ_NONE;
 
 	/* read the width/period values that were captured for the waveform */
-	data->width = get_gptimer_pwidth(TIMER5_id);
-	data->period = get_gptimer_period(TIMER5_id);
+	data->width = get_gptimer_pwidth(TEST_TMR_ID);
+	data->period = get_gptimer_period(TEST_TMR_ID);
 
 	/* acknowledge the interrupt */
-	clear_gptimer_intr(TIMER5_id);
+	clear_gptimer_intr(TEST_TMR_ID);
 
 	/* tell the upper layers we took care of things */
 	return IRQ_HANDLED;
@@ -48,25 +53,47 @@ static irqreturn_t gptimer_example_irq(int irq, void *dev_id)
 static int __init gptimer_example_init(void)
 {
 	int ret;
+	uint16_t revid;
 
 	/* grab the peripheral pins */
-	ret = peripheral_request(P_TMR5, DRIVER_NAME);
+	ret = peripheral_request(TEST_TMR_PIN, DRIVER_NAME);
 	if (ret) {
 		printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n");
 		return ret;
 	}
 
 	/* grab the IRQ for the timer */
-	ret = request_irq(IRQ_TIMER5, gptimer_example_irq, IRQF_SHARED, DRIVER_NAME, &data);
+	ret = request_irq(TEST_TMR_IRQ, gptimer_example_irq, IRQF_SHARED, DRIVER_NAME, &data);
 	if (ret) {
 		printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n");
-		peripheral_free(P_TMR5);
+		peripheral_free(P_TMR0);
 		return ret;
 	}
 
-	/* setup the timer and enable it */
-	set_gptimer_config(TIMER5_id, WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA);
-	enable_gptimers(TIMER5bit);
+#ifdef CONFIG_BF60x
+	revid = bfin_read16(TIMER_REVID);
+	printk("gptimer revid %04x\n", revid);
+	bfin_write16(TIMER_DATA_IMSK, 0);
+#endif
+
+#define TMR_MODE_PWM_ONESHOT
+/* #define TMR_MODE_PWM_CONT */
+
+#ifdef TMR_MODE_PWM_ONESHOT
+	/* setup one shot pwm timer and enable it */
+	set_gptimer_config(TEST_TMR_ID,  TIMER_OUT_DIS | TIMER_MODE_PWM | TIMER_PULSE_HI | TIMER_IRQ_WID_DLY);
+#endif
+#ifdef TMR_MODE_PWM_CONT
+	/* setup continuous timer and enable it */
+	set_gptimer_config(TEST_TMR_ID,  TIMER_OUT_DIS | TIMER_MODE_PWM_CONT | TIMER_PULSE_HI | TIMER_IRQ_PER);
+#endif
+
+	set_gptimer_pwidth(TEST_TMR_ID, 100);
+	set_gptimer_period(TEST_TMR_ID, 10000);
+#ifdef CONFIG_BF60x
+	set_gptimer_delay(TEST_TMR_ID, 0);
+#endif
+	enable_gptimers(TEST_TMR_BIT);
 
 	return 0;
 }
@@ -74,9 +101,9 @@ module_init(gptimer_example_init);
 
 static void __exit gptimer_example_exit(void)
 {
-	disable_gptimers(TIMER5bit);
-	free_irq(IRQ_TIMER5, &data);
-	peripheral_free(P_TMR5);
+	disable_gptimers(TEST_TMR_BIT);
+	free_irq(TEST_TMR_IRQ, &data);
+	peripheral_free(TEST_TMR_PIN);
 }
 module_exit(gptimer_example_exit);
 
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to