* question: How to toggle gpio when init_early
@ 2022-04-29 4:30 qianfan
2022-05-02 23:36 ` Samuel Holland
0 siblings, 1 reply; 3+ messages in thread
From: qianfan @ 2022-04-29 4:30 UTC (permalink / raw)
To: linux-sunxi
Hi everyone:
I want toggle a gpio when machine_desc->init_early, but failed.
The gpio is pd24, and I searched the datasheet of r40, the address of
PD_DAT register
is 0x01c20800 + 3 * 0x24 + 0x10. So I modify this register by
__raw_readl and __raw_writel.
The system can't startup when I adding those code.
Seems the physical address can't touch due to mmu.
Can I get some advice?
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question: How to toggle gpio when init_early
2022-04-29 4:30 question: How to toggle gpio when init_early qianfan
@ 2022-05-02 23:36 ` Samuel Holland
2022-05-05 0:23 ` qianfan
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Holland @ 2022-05-02 23:36 UTC (permalink / raw)
To: qianfan; +Cc: linux-sunxi
On 4/28/22 11:30 PM, qianfan wrote:
> Hi everyone:
>
> I want toggle a gpio when machine_desc->init_early, but failed.
>
> The gpio is pd24, and I searched the datasheet of r40, the address of PD_DAT
> register
> is 0x01c20800 + 3 * 0x24 + 0x10. So I modify this register by __raw_readl and
> __raw_writel.
> The system can't startup when I adding those code.
>
> Seems the physical address can't touch due to mmu.
> Can I get some advice?
You need to call ioremap() to get a virtual address for the MMIO region. But you
really should be using the GPIO API and not raw MMIO. And you really should be
using devicetree and not touching the machine description. For example, if this
is for a GPIO-connected watchdog or LED or regulator, Linux already has
devicetree drivers for these.
Regards,
Samuel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question: How to toggle gpio when init_early
2022-05-02 23:36 ` Samuel Holland
@ 2022-05-05 0:23 ` qianfan
0 siblings, 0 replies; 3+ messages in thread
From: qianfan @ 2022-05-05 0:23 UTC (permalink / raw)
To: Samuel Holland; +Cc: linux-sunxi
在 2022/5/3 7:36, Samuel Holland 写道:
> On 4/28/22 11:30 PM, qianfan wrote:
>> Hi everyone:
>>
>> I want toggle a gpio when machine_desc->init_early, but failed.
>>
>> The gpio is pd24, and I searched the datasheet of r40, the address of PD_DAT
>> register
>> is 0x01c20800 + 3 * 0x24 + 0x10. So I modify this register by __raw_readl and
>> __raw_writel.
>> The system can't startup when I adding those code.
>>
>> Seems the physical address can't touch due to mmu.
>> Can I get some advice?
> You need to call ioremap() to get a virtual address for the MMIO region. But you
I had searched the other mach, some of others has a map_io callback, which
create mmu rules by iotable_init. Copy that idea, I can toggle the gpio
pin.
> really should be using the GPIO API and not raw MMIO. And you really should be
> using devicetree and not touching the machine description. For example, if this
> is for a GPIO-connected watchdog or LED or regulator, Linux already has
> devicetree drivers for these.
Yes, I had enabled the gpio-wdt driver but the sunxi pinctrl/gpio driver
are registed to later. I had sniffer the hardware signals and found it
takes about 3 seconds when gpio-wdt driver ready after u-boot.
sunxi-pinctrl driver are deferred probe and ready when late_init.
Next is the console logs:
[ 0.265181] init_late
[ 0.293427] sun4i-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 1.760130] gpio_wdt start
So I want add something in machine_desc.
Seems there doesn't has a better way touching gpio watchdog before gpio-wdt
ready.
>
> Regards,
> Samuel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-05 0:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-29 4:30 question: How to toggle gpio when init_early qianfan
2022-05-02 23:36 ` Samuel Holland
2022-05-05 0:23 ` qianfan
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.