QPNP Haptic

QPNP (Qualcomm Technologies Plug N Play) Haptic is a peripheral on
Qualcomm Technologies PMICs.  The PMIC is connected to Host processor
via SPMI bus.

This device can be operated in four modes - direct, buffer,
pwm(pulse width modulation) and audio.

Required Properties:
 - compatible: must be "qcom,qpnp-haptic"
 - reg: address of device
 - qcom,pmic-revid : phandle to fetch PMIC revid
 - qcom,actuator-type: must be one of "erm" or "lra"
 - qcom,play-mode : must be one of "buffer", "direct", "pwm" or "audio"

Optional Properties:
 - qcom,timeout-ms: timeout in ms.
 - qcom,vmax-mv : maximum output voltage in milli volts
 - qcom,ilim-ma : maximum output current limit threshold in milli amps
 - qcom,int-pwm-freq-khz : frequency for internal pwm
 - qcom,en-brake : specify to enable internal reverse braking
 - qcom,brake-pattern : 4 byte active brake pattern. Each pattern represents
		2-bit amplitude control 0x00: 0, 0x01: vmax/4, 0x02: vmax/2,
		0x03: vmax. Default values are 0x00.
 - qcom,sc-deb-cycles : short circuit debounce in internal pwm switching clock cycles
 - interrupts:	Specifies the interrupt associated with Haptics. The available
		interrupts are play and short circuit. The values for play and
		short circuit are <0x3 0xc0 0x0> and <0x3 0xc0 0x1>.
 - interrupt-names: Specify the interrupt names associated with interrupts. Must be
		    one of "play-irq" or "sc-irq"
 - vcc_pon-supply: power-on driver regulator

Optional properties for buffer play mode:
 - qcom,wave-samples : 8 byte buffer representing the wave. The bits in each sample
		are represented as follows- bit 0: reserved, bits 1 to 5: amplitude
		of the waveform, bit 6: over drive and bit 7: direction.
 - qcom,wave-shape : must be "sine" or "square"
 - qcom,wave-rep-cnt : repetition count for wave form
 - qcom,wave-samp-rep-cnt : repetition count for each sample of wave
 - qcom,wave-play-rate-us : duration at which each sample to be played in micro seconds

Required properties for pwm play mode:
 - qcom,pwm-channel: pwm channel the led will operate on
 - qcom,period-us: pwm period in us
 - qcom,duty-us: pwm duty cycle in us
 - qcom,ext-pwm-dtest-line: dtest line to used with pwm

Optional properties for pwm play mode:
 - qcom,ext-pwm-freq-khz : frequency for external pwm in kilo HZ

Optional properties when qcom,actuator-type is "lra"
 - qcom,correct-lra-drive-freq : boolean, use this to ensure LRA is driven at correct resonant
				 frequency, which may change due to operating conditions.
 - qcom,pmic-misc		: phandle of misc device using which the clock
				  trim error can be read from.
 - qcom,misc-clk-trim-error-reg	: Address offset of MISC_TRIM_ERROR_RC19P2_CLK
				  register if present in MISC module. This
				  holds the frequency error in 19.2 MHz clock.
 - qcom,lra-auto-res-mode : auto resonance technique, four different modes
			"none" : no auto resonance
			"zxd" : zero crossing based discontinuous method
			"qwd" : quarter wave drive method
			"max-qwd" : Maximum QWD
			"zxd-eop" : ZXD + End of pattern (This is the Default)
 - qcom,lra-high-z : High Z configuration for auto resonance. Possible string values are
			"none", "opt1", "opt2" and "opt3" (default). For PM660,
			"opt0" is valid value for 1 LRA period.
 - qcom,lra-hw-auto-resonance : boolean, enable Hardware auto-resonance for PM660.
			Use this property to enable Hardware auto-resonance.
			If not defined then Software auto-resonance is enabled(default).
 - qcom,lra-qwd-drive-duration : Drive duration of LRA in QWD mode for PM660.
			Possible values are: 0: 1/4 LRA PERIOD and 1: 3/8 LRA PERIOD
 - qcom,lra-calibrate-at-eop : To calibrate at End of Pattern for PM660.
			Possible values are: 0 to disable and 1 to enable Calibration
			at End of Pattern
 - qcom,lra-res-cal-period : Auto resonance calibration period. The values range from
			4 to 32(default)
- qcom,lra-auto-mode : If this property is specified, haptics mode for LRA
		       actuators will be automatically configured along with
		       other required settings runtime based on the duration
		       of the pattern.
 - qcom,perform-lra-auto-resonance-search : boolean, define this property if:
		a) the underlying PMI chip does not have a register in the MISC block to
		read the error percentage in RC clock
		b) the actuator type is LRA
		Defining this causes the auto resonance search algorithm to be be performed
		for such devices.
		c) This property is not defined by default.

- qcom,drive-period-code-max-limit-percent-variation: RATE_CFG1 and RATE_CFG2 registers will
			be updated with the values from AUTO_RES_LO and AUTO_RES_HI registers
			only if the variation from the resonant frequency is within the value
			mentioned by this property on the higher side.
			The default value is 25, which means if the drive period code resulting
			from AUTO_RES register's is more than 25 percent of the existing drive
			period code, then driver does not update RATE_CFG registers.
- qcom,drive-period-code-min-limit-percent-variation: RATE_CFG1 and RATE_CFG2 registers will
			be updated with the values from AUTO_RES_LO and AUTO_RES_HI registers
			only if the variation from the resonant frequency is within the value
			mentioned by this property on the lower side.
                        The default value is 25, which means if the drive period code resulting
                        from AUTO_RES register's is less than 25 percent of the existing drive
                        period code, then driver does not update RATE_CFG registers.

Optional properties when qcom,lra-auto-res-mode is "qwd"
 - qcom,time-required-to-generate-back-emf-us: Time period required to generate sufficient
			back-emf (in case of QWD mode only) in us. For auto resonance
			detection to work properly,sufficient back-emf has to be
			generated. In general, back-emf takes some time to build up.
			When the auto resonance  mode is chosen as QWD, high-z will
			be applied for every LRA cycle and hence there won't be
			enough back-emf at the start-up. So we need to drive the
			motor for a few LRA cycles. Hence, auto resonance detection
			is enabled after this delay period after the PLAY bit is
			asserted. The default value is 20000us.

Example:
		qcom,haptic@c000 {
			status = "disabled";
			compatible = "qcom,qpnp-haptic";
			reg = <0xc000 0x100>;
			interrupts = <0x3 0xc0 0x0>,
				     <0x3 0xc0 0x1>;
			interrupt-names = "sc-irq", "play-irq";
			qcom,pmic-revid = <&pm660_revid>;
			vcc_pon-supply = <&pon_perph_reg>;
			qcom,pmic-misc = <&pmi8998_misc>;
			qcom,misc-clk-trim-error-reg = <0xf3>;
			qcom,play-mode = "direct";
			qcom,wave-play-rate-us = <5263>;
			qcom,actuator-type = "lra";
			qcom,wave-shape = "square";
			qcom,vmax-mv = <2000>;
			qcom,ilim-ma = <800>;
			qcom,sc-deb-cycles = <8>;
			qcom,int-pwm-freq-khz = <505>;
			qcom,en-brake;
			qcom,brake-pattern = [03 03 00 00];
			qcom,wave-samples = [3e 3e 3e 3e 3e 3e 3e 3e];
			qcom,wave-rep-cnt = <1>;
			qcom,wave-samp-rep-cnt = <1>;
			qcom,lra-high-z = "opt1";
			qcom,lra-auto-res-mode = "qwd";
			qcom,lra-res-cal-period = <4>;
			qcom,time-required-to-generate-back-emf-us = <20000>;
		};
