All of lore.kernel.org
 help / color / mirror / Atom feed
From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: AT91SAM9260: How to output PCK0 clock on a GPIO pin
Date: Tue, 01 Sep 2009 08:33:54 +1200	[thread overview]
Message-ID: <4A9C33B2.9060002@bluewatersys.com> (raw)
In-Reply-To: <b7beacff65dbf47b5e36c3480ec11085@colcan.ca>

Pedro I. Sanchez wrote:
> On Mon, 31 Aug 2009 23:33:12 +0400, Sergey Matyukevich <geomatsi@gmail.com>
> wrote:
>> Hi,
>>  
>>> And how do I turn on the PMC clocks for the GPIO?
>> Assigning gpio pin PC6 to TIOB2 peripheral is only a part of the work.
>> Timer counters may operate in different modes. Take a look at
>> the datasheet for at91sam9260, timer counters are covered in chapter 34. 
>> It looks like 'waveform mode' is what you need (see 34.5.10, 34.5.11).
>> Before you get desired output on PC6 pin you will have to turn on
>> waveform operating mode for TIOB2 and to configure its wave shapes.
>>  
>> Thanks,
>> Sergey
> 
> Thanks Sergey,
> 
> So are the following statements correct?
> 
> 1. The pck0 clock I've been playing with has nothing to do with the clock I
> want on PC6 (TIOB2).
> 
> 2. I have to use instead the "tc2_clk" as defined in
> arch/arm/mach-at-91/at91sam9260.c.
> 
> 3. I have to access the TC_CMR register directly to set things up. I mean,
> there are no macros already defined to access these structures.

Attached is a driver for outputting pwm's using the timer counters on
the at91 (sorry its not a proper patch, but this is just hauled out of
an old kernel we have). The driver is written for the 2.6.20 and does
not use the new at91 timer counter library. I think it should be
reasonably easy to port  to the mainline kernel (if you want to do this
for mainline inclusion, I'm happy to lend a hand).

To output a pwm on PC6, add the following code to your board file:

static struct at91_pwm_data pwm_data[] = {
	{
		.channel	= 2,
		.clock_div	= AT91_TC_SCLK,
		.period		= 500000,	/* Milliseconds */
		.tiob_duty	= 50,		/* Percentage */
		.tio		= AT91_TIOB,
	},
};

and in your board init function:

at91_add_device_pwm(pwm_data, ARRAY_SIZE(pwm_data));

The driver also exports the period, duty and raw ra, rb and rc counter
values via sysfs.

HTH,
~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

       Ryan Mallon                              Unit 5, Amuri Park
       Phone: +64 3 3779127                     404 Barbadoes St
       Fax:   +64 3 3779135                     PO Box 13 889
       Email: ryan at bluewatersys.com             Christchurch, 8013
       Web:   http://www.bluewatersys.com       New Zealand
       Freecall Australia  1800 148 751         USA 1800 261 2934
-------------- next part --------------
A non-text attachment was scrubbed...
Name: at91_pwm.c
Type: text/x-csrc
Size: 13254 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20090901/973113b0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: at91sam9260_devices.c
Type: text/x-csrc
Size: 3307 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20090901/973113b0/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: board.h
Type: text/x-chdr
Size: 587 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20090901/973113b0/attachment-0002.bin>

  reply	other threads:[~2009-08-31 20:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-31 15:32 AT91SAM9260: How to output PCK0 clock on a GPIO pin Pedro I. Sanchez
2009-08-31 16:58 ` Stephen Munnings
2009-08-31 18:27   ` Pedro I. Sanchez
2009-08-31 18:44     ` Stephen Munnings
2009-08-31 19:02       ` Pedro I. Sanchez
2009-08-31 19:13         ` Stephen Munnings
2009-08-31 19:21           ` Pedro I. Sanchez
2009-08-31 19:33     ` Sergey Matyukevich
2009-08-31 19:58       ` Stephen Munnings
2009-08-31 20:37         ` Pedro I. Sanchez
2009-08-31 20:44           ` Stephen Munnings
2009-08-31 21:09             ` Pedro I. Sanchez
2009-08-31 20:03       ` Pedro I. Sanchez
2009-08-31 20:33         ` Ryan Mallon [this message]
2009-08-31 20:46           ` Pedro I. Sanchez
2009-08-31 20:35         ` Sergey Matyukevich
2009-08-31 21:06           ` Pedro I. Sanchez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A9C33B2.9060002@bluewatersys.com \
    --to=ryan@bluewatersys.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.