Commit d92db750 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Enable TBCLK in control module for pwm

parent 56773342
......@@ -144,6 +144,21 @@ static int am335x_control_module_init(void)
return control_module_base == NULL;
}
int am335x_control_module_set(size_t offset, uint32_t bits)
{
uint32_t reg;
if (!control_module_base) {
if (am335x_control_module_init()) {
log_send(LOG_T_ERROR, "am335x: CONTROL_MODULE init failed");
return -1;
}
}
reg = am335x_read32(control_module_base, offset);
am335x_write32(control_module_base, offset, reg | bits);
}
int am335x_pinmux_debug(size_t offset)
{
uint32_t reg;
......
......@@ -69,6 +69,11 @@
#define AM335X_CONTROL_MODULE_CONF_LCD_DATA10 0x0c8 /* P8_36, 2: pwm1 A */
#define AM335X_CONTROL_MODULE_CONF_LCD_DATA11 0x0cc /* P8_34, 2: pwm1 B */
#define AM335X_CONTROL_MODULE_PWMSS_CTRL 0x664
#define AM335X_CONTROL_MODULE_PWMSS0_TBCLKEN 0x00000001
#define AM335X_CONTROL_MODULE_PWMSS1_TBCLKEN 0x00000002
#define AM335X_CONTROL_MODULE_PWMSS2_TBCLKEN 0x00000004
#define AM335X_PWMSS0_BASE 0x48300000
#define AM335X_PWMSS1_BASE 0x48302000
#define AM335X_PWMSS2_BASE 0x48304000
......@@ -359,4 +364,6 @@ int am335x_pinmux_set(size_t offset, unsigned mode, unsigned flags);
int am335x_pinmux_gpio_offset(int gpio, int pin, size_t *offset);
int am335x_control_module_set(size_t offset, uint32_t bits);
#endif /* _INCLUDE_AM335X_ */
......@@ -162,6 +162,7 @@ static struct controller_block * block_am335x_pwm_create(char *name, int argc, v
size_t pin_b;
unsigned mode_a;
unsigned mode_b;
uint32_t ctrl_bits;
pwm_nr = va_arg(ap, int);
if (pwm_nr < 0 || pwm_nr > 2) {
......@@ -177,6 +178,7 @@ static struct controller_block * block_am335x_pwm_create(char *name, int argc, v
pin_b = AM335X_CONTROL_MODULE_CONF_MCASP0_FSX;
mode_a = 1;
mode_b = 1;
ctrl_bits = AM335X_CONTROL_MODULE_PWMSS0_TBCLKEN;
break;
case 1:
offset = AM335X_PWMSS1_BASE;
......@@ -185,6 +187,7 @@ static struct controller_block * block_am335x_pwm_create(char *name, int argc, v
pin_b = AM335X_CONTROL_MODULE_CONF_LCD_DATA11;
mode_a = 2;
mode_b = 2;
ctrl_bits = AM335X_CONTROL_MODULE_PWMSS1_TBCLKEN;
break;
case 2:
offset = AM335X_PWMSS2_BASE;
......@@ -193,6 +196,7 @@ static struct controller_block * block_am335x_pwm_create(char *name, int argc, v
pin_b = AM335X_CONTROL_MODULE_CONF_LCD_DATA1;
mode_a = 3;
mode_b = 3;
ctrl_bits = AM335X_CONTROL_MODULE_PWMSS2_TBCLKEN;
break;
}
......@@ -200,6 +204,13 @@ static struct controller_block * block_am335x_pwm_create(char *name, int argc, v
log_send(LOG_T_ERROR, "%s: Enabling L4LS clock failed", name);
return NULL;
}
if (am335x_control_module_set(AM335X_CONTROL_MODULE_PWMSS_CTRL,
ctrl_bits)) {
log_send(LOG_T_ERROR,
"%s: Enabling TBCLK in control module failed", name);
return NULL;
}
if (am335x_cm_enable(cm_offset)) {
log_send(LOG_T_ERROR, "%s: Enabling module failed", name);
return NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment