LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-13-2019, 04:08 AM   #1
xsimonx
LQ Newbie
 
Registered: Aug 2019
Posts: 1

Rep: Reputation: Disabled
Pin modes - device tree / module


I am trying to write a linux device driver for a SPI device, using Atmels SAMA5d35 MPU. Linux version is 4.19.30.

I have configured the pins in my device tree and set the status to "okay". After that the pins changed mode as expected. My question is then, how do I manipulate pinmodes during runtime? My SPI device is not always on, neither is my driver always loaded. When that is the case I want the configured SPI pins to change mode to normal GPIOs (for power-consumption).

Is it the drivers task to do that, or is it something one can define in the device tree, when the driver for example is not loaded?

I have tried to implement a pinctrl-0 for setting the pins to SPI mode, and then a pinctrl-1 for setting the same pins to normal GPIOs. My idea was to switch between these pin configuration in the device driver, but unfortunately the device tree complaints about using the same pins for both pinctrl-0 and pinctrl-1 (compiles fine, but system wont boot). Although this was just my logical thoughts. I am sure there is a more correct way to do the things I stated above.





Code:
        spi0: spi@f0004000 {
            status = "okay";

            ext_adc: ads1258@1 {
                compatible = "ti,ads1258";
                pinctrl-names = "default", "sleep";
                pinctrl-0 = <&pinctrl_spi0_default>;
                pinctrl-1 = <&pinctrl_spi0_sleep>;
                reg = <1>;                                  /* Hardware chipselect SPI0_NPCS1 */
                spi-max-frequency = <16000000>;             /* According to datasheet */
                start-gpios = <&pioD 5 GPIO_ACTIVE_HIGH>;
                drdy-gpios = <&pioD 22 GPIO_ACTIVE_LOW>;
                enaadc-gpios = <&pioA 26 GPIO_ACTIVE_HIGH>; 
            };
        };
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
configure bias-pull-down for GPIO pin via device-tree overlay temoto Linux - Embedded & Single-board computer 2 06-04-2019 02:20 AM
Difference between "1R8 Single Rank 240 Pin" and "2R8 dual Rank 240 Pin" PatD Linux - Hardware 3 12-16-2017 12:33 PM
CPU 12-V power supply: 4-pin or 8-pin? michapma Linux - Hardware 3 07-23-2007 10:13 AM
the bible = the tree of the knowledge of good and evil () Jesus = the tree of life Michael111 General 2 04-14-2004 04:28 PM
need a P-Tree (Patricia Tree) library manaskb Programming 1 11-02-2002 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration