From: Antonio Ospite Date: Thu, 26 Jul 2018 10:56:46 +0000 (+0200) Subject: Initial import X-Git-Url: https://git.ao2.it/experiments/bbb-eqep2b-ao2.git/commitdiff_plain/c80f1b1f292d83b584798258b999d34fa86e936a Initial import --- c80f1b1f292d83b584798258b999d34fa86e936a diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c5d4c93 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +PART_NUMBER = bbb-eqep2b-ao2 +VERSION = 00A0 + +# To get the include files, clone the repository from +# https://github.com/beagleboard/bb.org-overlays.git +# parallel to this directory. + +INCLUDE_PATH = ../bb.org-overlays/include + +compile: $(PART_NUMBER)-$(VERSION).dtbo + +install: compile + cp $(PART_NUMBER)-$(VERSION).dtbo /lib/firmware + +clean: + rm -f *.dtbo *.dts.tmp *~ + +%.dtbo: %.dts + cpp -nostdinc -undef -D__DTS__ -I$(INCLUDE_PATH) -x assembler-with-cpp -o $<.tmp $< + dtc -Wno-unit_address_vs_reg -O dtb -o $@ -b 0 -@ $<.tmp diff --git a/bbb-eqep2b-ao2-00A0.dts b/bbb-eqep2b-ao2-00A0.dts new file mode 100644 index 0000000..0eaf9e3 --- /dev/null +++ b/bbb-eqep2b-ao2-00A0.dts @@ -0,0 +1,88 @@ +/* + * Set up eQEP in a way that does not conflict with HDMI. + * + * Copyright (C) 2013 Nathaniel R. Lewis - http://nathanielrlewis.com/ + * Copyright (C) 2018 Antonio Ospite + * + * This program is free softwarejc you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/dts-v1/; +/plugin/; + +#include +#include +#include + +/ { + compatible = "ti,beaglebone", "ti,beaglebone-black"; + + // Identification. + part-number = "bbb-eqep2b-ao2"; + version = "00A0"; + + // Resources this cape uses. + exclusive-use = + "P8.12", // EQEP2A_in + "P8.11", // EQEP2B_in + "P8.16", // EQEP2_index + "P8.15", // EQEP2_strobe + + "eqep2"; // hardware ip used + + fragment@0 { + target = <&am33xx_pinmux>; + __overlay__ { + pinctrl_eqep2: pinctrl_eqep2_pins { + pinctrl-single,pins = < + BONE_P8_12 (PIN_INPUT | MUX_MODE4) // GPIO1_12 = EQEP2A_in + BONE_P8_11 (PIN_INPUT | MUX_MODE4) // GPIO1_13 = EQEP2B_in + BONE_P8_16 (PIN_INPUT | MUX_MODE4) // GPIO1_14 = EQEP2_index + BONE_P8_15 (PIN_INPUT | MUX_MODE4) // GPIO1_15 = EQEP2_strobe + // From: https://groups.google.com/forum/#!searchin/beagleboard/eQep/beagleboard/Orp3tFcNgCc/mYacP_GkCQQJ + >; + }; + }; + }; + + fragment@1 { + target = <&epwmss2>; + __overlay__ { + status = "okay"; + }; + }; + + fragment@2 { + target = <&eqep2>; + __overlay__ { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_eqep2>; + + count_mode = <0>; // count_mode is not userspace op_mode + // 0 -> Quadrature mode, normal 90 phase offset cha & chb. + // 1 -> Direction mode. cha input = clock, chb input = direction + // 2 -> UP count mode for frequency measurement QDIR=1, ignore direction input + // 3 -> DOWN count mode for frequency measurement QDIR=0, ignore direction input + + swap_inputs = <0>; // swap channel A and B? (0 - no, 1 - yes) + invert_qa = <1>; // invert channel A input? + invert_qb = <1>; // invert channel B input? + invert_qi = <0>; // invert index input? + invert_qs = <0>; // invert strobe input? + omit_interrupt = <0>; // 1 -> do not install interrupt handler, 0 -> do install + + status = "okay"; + }; + }; +}; diff --git a/eQEP-test.sh b/eQEP-test.sh new file mode 100755 index 0000000..dd0e105 --- /dev/null +++ b/eQEP-test.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +while true; +do + cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position +done