struct mpc52xx_gpt *pwmf, *pwmb;
atomic_t pos;
int irq;
+ int action;
};
static ssize_t show_position(struct device *dev,
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
}
+static ssize_t show_action(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct motorek *m = platform_get_drvdata(pdev);
+
+ int len = snprintf(buf, PAGE_SIZE, "%d\n", m->action);
+ return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
+}
+
+static void motorek_action(struct motorek *m, int action_permile);
+static ssize_t store_action(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct motorek *m = platform_get_drvdata(pdev);
+
+ int a;
+ sscanf(buf, "%d", &a);
+ motorek_action(m, a);
+ return strnlen(buf, PAGE_SIZE);
+}
+
DEVICE_ATTR(position,0444,show_position,NULL);
+DEVICE_ATTR(action,0644,show_action,store_action);
#define MPC52xx_GPT_MODE_DISABLED 0
#define MPC52xx_GPT_MODE_INCAPT 1
static void motorek_action(struct motorek *m, int action_permile)
{
+ m->action = action_permile;
if (action_permile >= 0) {
pwm_width(m->pwmb, 0);
pwm_width(m->pwmf, +action_permile*PWM_PERIOD/1000);
{
pwm_init(m->pwmf);
pwm_init(m->pwmb);
-/* motorek_action(m, +45); */
- pwm_width(m->pwmb, 500);
- pwm_width(m->pwmf, 500);
+ //motorek_action(m, +0);
return 0;
}
if (prop) {
i = *(u32 *)prop;
switch (i) {
- case 1:
+ case 2:
m->pwmf = of_iomap(np, 0);
break;
- case 2:
+ case 3:
m->pwmb = of_iomap(np, 0);
break;
}
platform_set_drvdata(dev, m);
err = device_create_file(&dev->dev,&dev_attr_position);
+ if (err)
+ return err;
+ err = device_create_file(&dev->dev,&dev_attr_action);
if (err)
return err;