+if [ $(cat $slot | grep am33xx_pwm -c) -gt 0 ]; then
+ echo am33xx_pwm already loaded, not loading again;
+else
+ echo Enabling PWM driver am33xx_pwm
+ echo am33xx_pwm > $slot
+fi;
+
+# Safe pins that won't interfere with one another
+#ports=(P9_22 P9_42 P9_16 P8_13 P9_28);
+#portnumbers=(0 2 4 6 7);
+#Full correspondence from pwm0-pwm7
+ports=(P9_22 P9_21 P9_42 P9_14 P9_16 P8_19 P8_13 P9_28);
+portnumbers=(0 1 2 3 4 5 6 7);
+# Enable PWM pins
+# They must be exported at this stage, before the device tree
+# overlay for that pin is enabled.
+for ((c=0; c < ${#ports[*]}; c++)); do
+ if [ ! -d $pwm/pwm${portnumbers[$c]} ]; then
+ echo Exporting PWM ${portnumbers[$c]} \(${ports[$c]}\)
+ echo ${portnumbers[$c]} > $pwm/export
+ else
+ echo PWM ${portnumbers[$c]} already enabled
+ fi;
+
+ if [ $(cat $slot | grep ${ports[$c]} -c) -gt 0 ]; then
+ echo PWM pin ${ports[$c]} already enabled, not enabling again
+ else
+ (echo bone_pwm_${ports[$c]} > $slot) 1>&2 >> /dev/null
+ fi;
+done;