Home > other >  [for] [consult Linux driver] [PWM subsystem] [device tree devm_of_pwm_get] [stuck]
[for] [consult Linux driver] [PWM subsystem] [device tree devm_of_pwm_get] [stuck]

Time:05-14

Consult: set up a PWM pin in the device tree, the work is normal, but set up two PWM pins, Linux load driver is crashed and unknown folded, equipment the root directory and iomuxc:
 
Fs_pwm {
Compatible="fs_pwm";
Pinctrl - names="default";
Pinctrl - 0=& lt; & Pinctrl_fspwm & gt;;
Pwm_power {
PWM - names="pwm_power";
PWMS=& lt; & Pwm1 0 50000 & gt;;
};
Pwm_motor {
PWM - names="pwm_motor";
PWMS=& lt; & Pwm2 0 50000 & gt;;
};

};

 
Pinctrl_fspwm: FSPWMGRP {
FSL, pins=& lt;
MX6UL_PAD_LCD_DATA00__PWM1_OUT 0 x1b0b0/*/pwm1 & amp; Motor PWM */
MX6UL_PAD_LCD_DATA01__PWM2_OUT 0 x1b0b0/*/pwm1 & amp; Motor PWM */
& gt;;

Read nodes:
 
Struct pwm_device * pwm_power_dev=NULL;//define PWM device structure
Struct pwm_device * pwm_motor_dev=NULL;
*//* lite version prob function
Static int pwm_power_probe_new (struct platform_device * pdev)
{
Int ret=0;
Struct device_node * child;
Struct device_node * child2;
Struct device * dev=& amp; Pdev - & gt; Dev.
Printk (" the match success \ n ");

The child=of_get_next_child (dev - & gt; Of_node, NULL);
Printk (" \ "% s " 's child: \ \ "% s" \ n ", dev - & gt; Of_node - & gt; Full_name, child - & gt; Full_name);
Printk (" % s % s line % d \ r \ n "__FILE__, __FUNCTION__, __LINE__);
If (child) NULL==
{
Printk (" of_get_next_child error \ r \ n ");
}
If (child)
{
Pwm_power_dev=devm_of_pwm_get (dev, child, NULL);
If (IS_ERR (pwm_power_dev))
{
Printk (KERN_ERR to "pwm_power_dev, get PWM error!!!!! \n");
return -1;
}

//pwm_motor_dev=devm_of_pwm_get (dev, Chile,)
}
The else
{
Printk (KERN_ERR to "pwm_power_dev of_get_next_child error!!!!! \n");
return -1;
}

Child2=of_get_next_child (dev - & gt; Of_node, child);

Printk (" \ "% s " 's child2: \ \ "% s" \ n ", dev - & gt; Of_node - & gt; Full_name, child2 - & gt; Full_name);
Printk (" \ "% s " 's child2: \ \ "% s" \ n ", dev - & gt; Of_node - & gt; Full_name, child2 - & gt; Full_name);
Printk (" \ "% s " 's child2: \ \ "% s" \ n ", dev - & gt; Of_node - & gt; Full_name, child2 - & gt; Full_name);
Printk (" % s % s line % d \ r \ n "__FILE__, __FUNCTION__, __LINE__);
If (NULL==child2)
{
Printk (" of_get_next_child2 error \ r \ n ");
}
If (child2)
{
If (IS_ERR (child2))
{
Printk (KERN_ERR to "of_get_next_child, child2 error!!!!! \n");
return -1;
}

Printk (" \ "% s " 's devm_of_pwm_get: \ \ "% s" \ n ", dev - & gt; Of_node - & gt; Full_name, child2 - & gt; Full_name);
Pwm_motor_dev=devm_of_pwm_get (dev, child2, NULL);//* * * * this code crashes, no longer run down

If (IS_ERR (pwm_motor_dev))
{
Printk (KERN_ERR to "pwm_power_dev, get PWM error!!!!! \n");
return -1;
}
}
The else
{
Printk (KERN_ERR to "pwm_power_dev of_get_next_child error!!!!! \n");
return -1;
}

Printk (" set pwm_power... \r\n");

/* configuration frequency of 100 KHZ duty ratio 80% */
Ret=pwm_config (pwm_power_dev, 1000, 5000);
Printk (" ret: % d \ r \ n ", ret);
/* inverting frequency of 100 KHZ duty ratio 20% */
Ret=pwm_set_polarity (pwm_power_dev PWM_POLARITY_INVERSED);
Printk (" ret: % d \ r \ n ", ret);
Ret=pwm_enable (pwm_power_dev);
Printk (" ret: % d \ r \ n ", ret);

Printk (" set pwm_motor... \r\n");
/* configuration frequency of 100 KHZ duty ratio 80% */
Ret=pwm_config (pwm_motor_dev, 1000, 5000);
Printk (" ret: % d \ r \ n ", ret);
/* inverting frequency of 100 KHZ duty ratio 20% */
Ret=pwm_set_polarity (pwm_motor_dev PWM_POLARITY_NORMAL);
Printk (" ret: % d \ r \ n ", ret);
Ret=pwm_enable (pwm_motor_dev);
Printk (" ret: % d \ r \ n ", ret);

Return ret.
}
  • Related