I.MX6 Multiplexer GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I.MX6 Multiplexer GPIO

Jump to solution
10,723 Views
grégorycascio
Contributor I

Hey,

I have a board Emtrion dimm mx6, with imx6q freescale processor.


When I bought the board there was no pwm initialized at boot. I booted my pwm with the command imx_add_pwm (1).


In my board three port pin (GPIO4/5/6) can be used as pwm outputs (GPIO4=PWM1 in my case)


I can not see my signal on my GPIO4. Emtrion told me that it was a problem multiplexing.


What should I do to make my gpio mode pwm.


best regard



0 Kudos
1 Solution
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

I think you can just do necessary config in uboot, then monitor the output of PWM pin, there should be PWM signal.

For kernel, if you use PWM1, you should add imx6q_add_mxc_pwm(0); there is 4 PWM modules in our SOC. You use GPIO_9(_MX6Q_PAD_GPIO_9__PWM1_PWMO), so it is PWM1, our map from virtual PWMx to hwid is as below, so PWM1 is mapped to virtual ID 0, so you should use imx6q_add_mxc_pwm(0);

65 imx6q_mxc_pwm_data_entry(0, 1),

66 imx6q_mxc_pwm_data_entry(1, 2),

67 imx6q_mxc_pwm_data_entry(2, 3),

68 imx6q_mxc_pwm_data_entry(3, 4),

Best Regards.

Anson huang 黄勇才

Freescale Semiconductor Shanghai

上海浦东新区亮景路192号A座2楼

201203

Tel:021-28937058

View solution in original post

0 Kudos
14 Replies
2,785 Views
AnsonHuang
NXP Employee
NXP Employee

Hi, cascio

     What do you mean by gopi mode pwm? you mean you want to config this pin as GPIO, then use GPIO low/high signal to output PWM signal? Or, you want some pin to config as a PWM pin, then use internal PWM module to output PWM signal. Can you tell me which pin(from schematic) you want to use as PWM output?

0 Kudos
2,786 Views
grégorycascio
Contributor I

Hi Yongcai,

Yes, I want to generate an internal PWM signal (Signal Sodimm : GPIO4, i.MX6 port : GPIO1_9, Direction : In/Out, GPIO number  : 9) which connect in another GPIO.

GPIO4 can also be used as PWM (PWM 1 : pin 12 connector J12)


My board is a Verno4.
http://www.support.emtrion.de/doku.php?id=emsdk:mx6_gpio_details


best regards,



0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

Sorry, I can NOT see GPIO_4 can be set as PWM, from below IOMUX definition of i.MX6Q, there is no PWM mux for GPIO_4. Only GPIO_9 can be set as PWM.

2372 #define _MX6Q_PAD_GPIO_4__ESAI1_HCKT                    \

2373                 IOMUX_PAD(0x0608, 0x0238, 0, 0x0868, 1, 0)

2374 #define _MX6Q_PAD_GPIO_4__OBSERVE_MUX_OBSRV_INT_OUT3            \

2375                 IOMUX_PAD(0x0608, 0x0238, 1, 0x0000, 0, 0)

2376 #define _MX6Q_PAD_GPIO_4__KPP_COL_7                     \

2377                 IOMUX_PAD(0x0608, 0x0238, 2, 0x08F0, 1, 0)

2378 #define _MX6Q_PAD_GPIO_4__CCM_CCM_OUT_2                 \

2379                 IOMUX_PAD(0x0608, 0x0238, 3, 0x0000, 0, 0)

2380 #define _MX6Q_PAD_GPIO_4__CSU_CSU_ALARM_AUT_1           \

2381                 IOMUX_PAD(0x0608, 0x0238, 4, 0x0000, 0, 0)

2382 #define _MX6Q_PAD_GPIO_4__GPIO_1_4                      \

2383                 IOMUX_PAD(0x0608, 0x0238, 5, 0x0000, 0, 0)

2384 #define _MX6Q_PAD_GPIO_4__USDHC2_CD                     \

2385                 IOMUX_PAD(0x0608, 0x0238, 6, 0x0000, 0, 0)

2386 #define _MX6Q_PAD_GPIO_4__OCOTP_CTRL_WRAPPER_FUSE_LATCHED               \

2387                 IOMUX_PAD(0x0608, 0x0238, 7, 0x0000, 0, 0)

2,786 Views
grégorycascio
Contributor I

Hi Yongcai,

you're right it's well gpio_9 for pwm,


#define _MX6Q_PAD_GPIO_9__ESAI1_FSR   \
  IOMUX_PAD(0x05F8, 0x0228, 0, 0x085C, 1, 0)
#define _MX6Q_PAD_GPIO_9__WDOG1_WDOG_B   \
   IOMUX_PAD(0x05F8, 0x0228, 1, 0x0000, 0, 0)
#define _MX6Q_PAD_GPIO_9__KPP_COL_6   \
   IOMUX_PAD(0x05F8, 0x0228, 2, 0x08EC, 0, 0)
#define _MX6Q_PAD_GPIO_9__CCM_REF_EN_B   \
   IOMUX_PAD(0x05F8, 0x0228, 3, 0x0000, 0, 0)
#define _MX6Q_PAD_GPIO_9__PWM1_PWMO   \
   IOMUX_PAD(0x05F8, 0x0228, 4, 0x0000, 0, 0)
#define _MX6Q_PAD_GPIO_9__GPIO_1_9   \
   IOMUX_PAD(0x05F8, 0x0228, 5, 0x0000, 0, 0)
#define _MX6Q_PAD_GPIO_9__USDHC1_WP   \
   IOMUX_PAD(0x05F8, 0x0228, 6, 0x094C, 1, 0)
#define _MX6Q_PAD_GPIO_9__SRC_EARLY_RST   \
   IOMUX_PAD(0x05F8, 0x0228, 7, 0x0000, 0, 0)

How do I activate the pwm function so that I can use.

I added a file (board-mx6q-dimm-mx6.h) the following commands :

/* PWM */

    MX6Q_PAD_GPIO_9__PWM1_PWMO,

    MX6Q_PAD_GPIO_9__GPIO_1_9,

is that enough?

0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

Hi, cascio

     Please mark this question as answered after you think it is solved, thanks:)

0 Kudos
2,786 Views
grégorycascio
Contributor I

Hi Yongcai,


How do I see if the driver pwm is running ?

0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

You can check whether pwm drivers probe routine is executed successfully. And run some unit test to see whether it works.

And, as pwm is a simple module, if you meet problem, you can even test it in uboot, just config registers to output pwm signal then monitor the output on the board.

Sent from Anson's iPhone

在 2013-7-11,16:45,"cascio grégory" <admin@community.freescale.com<mailto:admin@community.freescale.com>> 写道:

Freescale Community<https://community.freescale.com/index.jspa>

<https://community.freescale.com/index.jspa>

I.MX6 Multiplexer GPIO

created by cascio grégory<https://community.freescale.com/people/gr%C3%A9gorycascio> in i.MX Community - View the full discussion<https://community.freescale.com/message/339471#339471>

0 Kudos
2,786 Views
grégorycascio
Contributor I

How can I test if the PWM is running ??


I created a test module (pwm.c) but I do not know if it is right. If you can take a look.


#include <linux/module.h>    /* Needed by all modules */

#include <linux/kernel.h>    /* Needed for KERN_INFO */

#include <linux/init.h>

#include <linux/pwm.h>

#include <linux/err.h>

#include <linux/platform_device.h>

#include <linux/dma-mapping.h>

#include <linux/gpio.h>

static void *dev;

static int __init init_pwm(void)

{

    int err;

    dev = pwm_request(1, "PWM_DSP");

    if(dev == ERR_PTR(-EBUSY))

    {

        printk(KERN_INFO "C OQP\n");

        return -1;

    }

    if(dev == ERR_PTR(-ENOENT))

    {

        printk(KERN_INFO "YA PAS TROUVE\n");

        return -1;

    }

    if ((err = pwm_enable(dev)) != 0)

    {

        printk(KERN_INFO "ERREUR DEMARRAGE PWM\n");

        return err;

    }

    if ((err = pwm_config(dev, 250000, 500000)) != 0) //250µs-500µs

    {

        printk(KERN_INFO "ERREUR CONFIG\n");

        return err;

    }

    printk(KERN_INFO "PWM module loaded and started.\n");

    /*

     * A non 0 return means init_module failed; module can't be loaded.

     */

    return 0;

}

static void __exit end_pwm(void)

{

    pwm_disable(dev);

    pwm_free(dev);

    printk(KERN_INFO "PWM module finished.\n");

}

module_init(init_pwm);

module_exit(end_pwm);

MODULE_LICENSE("GPL");


0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

Sorry, I am not familiar with PWM driver, can you do some debug? Normally, the LCD backlight is using PWM, so if there is backlight on, it should be working, you can monitor the output of PWM pin. If it didn't work, you may need to look into the register config of PWM.

0 Kudos
2,786 Views
grégorycascio
Contributor I

Hi Yongcai,

Normally, the LCD backlight works because my lcd screen is lit.

pwm to initialize the boot we must use imx6q_add_pwm (number of pwm) ??


Is there a way to test if my PWM is enabled (or run) at the start of the board? (can you tell me the manipulation has perform)

0 Kudos
2,787 Views
AnsonHuang
NXP Employee
NXP Employee

I think you can just do necessary config in uboot, then monitor the output of PWM pin, there should be PWM signal.

For kernel, if you use PWM1, you should add imx6q_add_mxc_pwm(0); there is 4 PWM modules in our SOC. You use GPIO_9(_MX6Q_PAD_GPIO_9__PWM1_PWMO), so it is PWM1, our map from virtual PWMx to hwid is as below, so PWM1 is mapped to virtual ID 0, so you should use imx6q_add_mxc_pwm(0);

65 imx6q_mxc_pwm_data_entry(0, 1),

66 imx6q_mxc_pwm_data_entry(1, 2),

67 imx6q_mxc_pwm_data_entry(2, 3),

68 imx6q_mxc_pwm_data_entry(3, 4),

Best Regards.

Anson huang 黄勇才

Freescale Semiconductor Shanghai

上海浦东新区亮景路192号A座2楼

201203

Tel:021-28937058

0 Kudos
2,786 Views
grégorycascio
Contributor I

I have added the lines imx6q_add_mxc_pwm (0) and MX6Q_PAD_GPIO_9__PWM1_PWMO.


If I understand these two lines allows me to activate the signal pwm1.


is there a way to operate the PWM without creating a module ?

(

like a GPIO :
echo 30 > /sys/class/gpio/export

echo "out or in" > /sys/class/gpio/gpio30/direction

echo 1 or 0 > /sys/class/gpio/gpio30/value

)



0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

Just config PWM register directly can make it work.

I just tried it on our i.MX6Q sabreSD board, I config GPIO_9 to PWMO, then measure GPIO_9 pin, I can see there is PWM signal output because our uboot already enable this PWM. Attached is the PWM driver in uboot, just call imx_pwm_config(pwm0, 25000, 50000); and imx_pwm_enable(pwm0); there will be output from PWM1.

You can refer to it. If you want to test it in kernel, you can use memtool to config PWM register directly. I guess you want to see whether PWM hardware is working, right? Look at the attached file, it is working.

Best Regards.

Anson huang 黄勇才

Freescale Semiconductor Shanghai

上海浦东新区亮景路192号A座2楼

201203

Tel:021-28937058

0 Kudos
2,786 Views
AnsonHuang
NXP Employee
NXP Employee

Hi, cascio

     I think you should only add one line: MX6Q_PAD_GPIO_9__PWM1_PWMO, as one physical pin can only be enabled as one function, if you add two lines, the second line will config this pin to GPIO_1_9, it will be an general GPIO function pin, now PWM output pin.

     If you only need the first line code, then make sure PWM driver is running, there should be output from this pin.

0 Kudos