12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850 |
- /* Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver.
- * Copyright (c) 2007-2012, Synaptics Incorporated
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <asm/unaligned.h>
- #include <mach/cpufreq.h>
- #include <linux/slab.h>
- #include <linux/i2c.h>
- #include <linux/interrupt.h>
- #include <linux/delay.h>
- #include <linux/input.h>
- #include <linux/input/mt.h>
- #include <linux/gpio.h>
- #include <linux/regulator/consumer.h>
- #ifdef CONFIG_HAS_EARLYSUSPEND
- #include <linux/earlysuspend.h>
- #endif
- #include "synaptics_i2c_rmi.h"
- #include "synaptics_rmi.h"
- #include <linux/of_gpio.h>
- #include <linux/regulator/consumer.h>
- #define DRIVER_NAME "synaptics_rmi4_i2c"
- #define PROXIMITY
- #define TYPE_B_PROTOCOL
- #ifdef SURFACE_TOUCH
- #define EDGE_SWIPE
- #endif
- #undef USE_SENSOR_SLEEP
- /*#define REPORT_2D_Z*/
- #define REPORT_2D_W
- #define F12_FINGERS_TO_SUPPORT 10
- #define RPT_TYPE (1 << 0)
- #define RPT_X_LSB (1 << 1)
- #define RPT_X_MSB (1 << 2)
- #define RPT_Y_LSB (1 << 3)
- #define RPT_Y_MSB (1 << 4)
- #define RPT_Z (1 << 5)
- #define RPT_WX (1 << 6)
- #define RPT_WY (1 << 7)
- #define RPT_DEFAULT (RPT_TYPE | RPT_X_LSB | RPT_X_MSB | RPT_Y_LSB | RPT_Y_MSB)
- #ifdef CONFIG_GLOVE_TOUCH
- #define GLOVE_FEATURE_EN 0x20
- #define GLOVE_CLEAR_DEFAULT 0x00
- #endif
- #ifdef PROXIMITY
- #define USE_CUSTOM_REZERO
- #define HOVER_Z_MAX (255)
- #define FINGER_HOVER_EN (1 << 0)
- #define FINGER_HOVER_DIS (0 << 0)
- #define AIR_SWIPE_EN (1 << 1)
- #define LARGE_OBJ_EN (1 << 2)
- #define HOVER_PINCH_EN (1 << 3)
- #define NO_PROXIMITY_ON_TOUCH_EN (1 << 5)
- #define CONTINUOUS_LOAD_REPORT_EN (1 << 6)
- #define SLEEP_PROXIMITY (1 << 7)
- #define PROXIMITY_DEFAULT (NO_PROXIMITY_ON_TOUCH_EN)
- #define PROXIMITY_ENABLE (PROXIMITY_DEFAULT | FINGER_HOVER_EN)
- #define HAS_FINGER_HOVER (1 << 0)
- #define HAS_AIR_SWIPE (1 << 1)
- #define HAS_LARGE_OBJ (1 << 2)
- #define HAS_HOVER_PINCH (1 << 3)
- #define HAS_EDGE_SWIPE (1 << 4)
- #define HAS_SINGLE_FINGER (1 << 5)
- #define F51_VERSION 0x41
- #define F51_PROXIMITY_ENABLES_OFFSET (0)
- #define F51_CTRL54_OFFSET 99
- #ifdef USE_CUSTOM_REZERO
- #define F51_GENERAL_CONTROL_OFFSET (1)
- #define F51_CTRL78_OFFSET 115
- #endif
- #ifdef EDGE_SWIPE
- #define EDGE_SWIPE_DATA_OFFSET 8
- #define EDGE_SWIPE_WIDTH_MAX 255
- #define EDGE_SWIPE_PALM_MAX 1
- #endif
- #define F51_FINGER_TIMEOUT 50 /* ms */
- #endif
- #define POLLING_PERIOD 1 /* ms */
- #define SYN_I2C_RETRY_TIMES 3
- #define MAX_F11_TOUCH_WIDTH 15
- #define CHECK_STATUS_TIMEOUT_MS 200
- #define STATUS_NO_ERROR 0x00
- #define STATUS_RESET_OCCURRED 0x01
- #define STATUS_INVALID_CONFIG 0x02
- #define STATUS_DEVICE_FAILURE 0x03
- #define STATUS_CONFIG_CRC_FAILURE 0x04
- #define STATUS_FIRMWARE_CRC_FAILURE 0x05
- #define STATUS_CRC_IN_PROGRESS 0x06
- #define F01_STD_QUERY_LEN 21
- #define F01_BUID_ID_OFFSET 18
- #define F11_STD_QUERY_LEN 9
- #define F11_STD_CTRL_LEN 10
- #define F11_STD_DATA_LEN 12
- #define NORMAL_OPERATION (0 << 0)
- #define SENSOR_SLEEP (1 << 0)
- #define NO_SLEEP_OFF (0 << 2)
- #define NO_SLEEP_ON (1 << 2)
- #define CHARGER_CONNECTED (1 << 5)
- #define CHARGER_DISCONNECTED 0xDF
- #define CONFIGURED (1 << 7)
- #define TSP_NEEDTO_REBOOT (-ECONNREFUSED)
- #define MAX_TSP_REBOOT 3
- #if defined(CONFIG_SEC_MELIUSCA_PROJECT)
- #define SYNAPTICS_MAX_X_SIZE 719
- #define SYNAPTICS_MAX_Y_SIZE 1279
- #else
- #define SYNAPTICS_MAX_X_SIZE 1079
- #define SYNAPTICS_MAX_Y_SIZE 1919
- #endif
- #define SYNAPTICS_MAX_WIDTH SYNAPTICS_MAX_Y_SIZE
- #define NUM_RX 28
- #define NUM_TX 16
- #ifdef TSP_PATTERN_TRACKING_METHOD
- #define MAX_GHOSTCHECK_FINGER 10
- #define MAX_GHOSTTOUCH_COUNT 5
- #define MAX_COUNT_TOUCHSYSREBOOT 4
- #define MAX_GHOSTTOUCH_BY_PATTERNTRACKING 3
- #define PATTERN_TRACKING_DISTANCE 4
- #define TSP_REBOOT_PENDING_TIME 50
- #define MOVE_COUNT_TH 100
- /* Each project has different edge config,
- so check this value before applying pattern tracking */
- #define MIN_X_EDGE 17
- #define MAX_X_EDGE 1060 //1062
- #define MIN_Y_EDGE 17
- #define MAX_Y_EDGE 1900 // 1902
- /* Below is used for clearing ghost touch or for checking to system reboot. by Xtopher */
- static int tcount_finger[MAX_GHOSTCHECK_FINGER] = {0,0,0,0,0,0,0,0,0,0};
- static int touchbx[MAX_GHOSTCHECK_FINGER] = {0,0,0,0,0,0,0,0,0,0};
- static int touchby[MAX_GHOSTCHECK_FINGER] = {0,0,0,0,0,0,0,0,0,0};
- static int ghosttouchcount = 0;
- static bool tsp_pattern_tracking(int fingerindex, int x, int y, bool movecheck);
- #endif
- extern void mdss_dsi_panel_touchsensing(int enable);
- void synaptics_power_ctrl(struct synaptics_rmi4_data *rmi4_data, bool enable);
- static int synaptics_rmi4_i2c_read(struct synaptics_rmi4_data *rmi4_data,
- unsigned short addr, unsigned char *data,
- unsigned short length);
- static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
- unsigned short addr, unsigned char *data,
- unsigned short length);
- static int synaptics_rmi4_reinit_device(struct synaptics_rmi4_data *rmi4_data);
- static int synaptics_rmi4_reset_device(struct synaptics_rmi4_data *rmi4_data);
- static int synaptics_rmi4_stop_device(struct synaptics_rmi4_data *rmi4_data);
- static int synaptics_rmi4_start_device(struct synaptics_rmi4_data *rmi4_data);
- #ifdef CONFIG_HAS_EARLYSUSPEND
- static ssize_t synaptics_rmi4_full_pm_cycle_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_full_pm_cycle_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count);
- static void synaptics_rmi4_early_suspend(struct early_suspend *h);
- static void synaptics_rmi4_late_resume(struct early_suspend *h);
- #else
- static int synaptics_rmi4_suspend(struct device *dev);
- static int synaptics_rmi4_resume(struct device *dev);
- #endif
- #ifdef PROXIMITY
- static void synaptics_rmi4_f51_finger_timer(unsigned long data);
- static ssize_t synaptics_rmi4_f51_enables_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_f51_enables_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count);
- #endif
- #ifdef USE_OPEN_CLOSE
- static int synaptics_rmi4_input_open(struct input_dev *dev);
- static void synaptics_rmi4_input_close(struct input_dev *dev);
- #ifdef USE_OPEN_DWORK
- static void synaptics_rmi4_open_work(struct work_struct *work);
- #endif
- #endif
- static ssize_t synaptics_rmi4_f01_reset_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count);
- static ssize_t synaptics_rmi4_f01_productinfo_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_f01_buildid_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_f01_flashprog_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_0dbutton_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- static ssize_t synaptics_rmi4_0dbutton_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count);
- struct synaptics_rmi4_f01_device_status {
- union {
- struct {
- unsigned char status_code:4;
- unsigned char reserved:2;
- unsigned char flash_prog:1;
- unsigned char unconfigured:1;
- } __packed;
- unsigned char data[1];
- };
- };
- struct synaptics_rmi4_f12_query_5 {
- union {
- struct {
- unsigned char size_of_query6;
- struct {
- unsigned char ctrl0_is_present:1;
- unsigned char ctrl1_is_present:1;
- unsigned char ctrl2_is_present:1;
- unsigned char ctrl3_is_present:1;
- unsigned char ctrl4_is_present:1;
- unsigned char ctrl5_is_present:1;
- unsigned char ctrl6_is_present:1;
- unsigned char ctrl7_is_present:1;
- } __packed;
- struct {
- unsigned char ctrl8_is_present:1;
- unsigned char ctrl9_is_present:1;
- unsigned char ctrl10_is_present:1;
- unsigned char ctrl11_is_present:1;
- unsigned char ctrl12_is_present:1;
- unsigned char ctrl13_is_present:1;
- unsigned char ctrl14_is_present:1;
- unsigned char ctrl15_is_present:1;
- } __packed;
- struct {
- unsigned char ctrl16_is_present:1;
- unsigned char ctrl17_is_present:1;
- unsigned char ctrl18_is_present:1;
- unsigned char ctrl19_is_present:1;
- unsigned char ctrl20_is_present:1;
- unsigned char ctrl21_is_present:1;
- unsigned char ctrl22_is_present:1;
- unsigned char ctrl23_is_present:1;
- } __packed;
- struct {
- unsigned char ctrl24_is_present:1;
- unsigned char ctrl25_is_present:1;
- unsigned char ctrl26_is_present:1;
- unsigned char ctrl27_is_present:1;
- unsigned char ctrl28_is_present:1;
- unsigned char ctrl29_is_present:1;
- unsigned char ctrl30_is_present:1;
- unsigned char ctrl31_is_present:1;
- } __packed;
- };
- unsigned char data[5];
- };
- };
- struct synaptics_rmi4_f12_query_8 {
- union {
- struct {
- unsigned char size_of_query9;
- struct {
- unsigned char data0_is_present:1;
- unsigned char data1_is_present:1;
- unsigned char data2_is_present:1;
- unsigned char data3_is_present:1;
- unsigned char data4_is_present:1;
- unsigned char data5_is_present:1;
- unsigned char data6_is_present:1;
- unsigned char data7_is_present:1;
- } __packed;
- };
- unsigned char data[2];
- };
- };
- struct synaptics_rmi4_f12_ctrl_8 {
- union {
- struct {
- unsigned char max_x_coord_lsb;
- unsigned char max_x_coord_msb;
- unsigned char max_y_coord_lsb;
- unsigned char max_y_coord_msb;
- unsigned char rx_pitch_lsb;
- unsigned char rx_pitch_msb;
- unsigned char tx_pitch_lsb;
- unsigned char tx_pitch_msb;
- unsigned char low_rx_clip;
- unsigned char high_rx_clip;
- unsigned char low_tx_clip;
- unsigned char high_tx_clip;
- unsigned char num_of_rx;
- unsigned char num_of_tx;
- };
- unsigned char data[14];
- };
- };
- struct synaptics_rmi4_f12_ctrl_9 {
- union {
- struct {
- unsigned char touch_threshold;
- unsigned char lift_hysteresis;
- unsigned char small_z_scale_factor_lsb;
- unsigned char small_z_scale_factor_msb;
- unsigned char large_z_scale_factor_lsb;
- unsigned char large_z_scale_factor_msb;
- unsigned char small_large_boundary;
- unsigned char wx_scale;
- unsigned char wx_offset;
- unsigned char wy_scale;
- unsigned char wy_offset;
- unsigned char x_size_lsb;
- unsigned char x_size_msb;
- unsigned char y_size_lsb;
- unsigned char y_size_msb;
- unsigned char gloved_finger;
- };
- unsigned char data[16];
- };
- };
- struct synaptics_rmi4_f12_ctrl_23 {
- union {
- struct {
- unsigned char obj_type_enable;
- unsigned char max_reported_objects;
- };
- unsigned char data[2];
- };
- };
- #ifdef CONFIG_GLOVE_TOUCH
- struct synaptics_rmi4_f12_ctrl_26 {
- union {
- struct {
- unsigned char glove_feature_enable;
- };
- unsigned char data[1];
- };
- };
- #endif
- struct synaptics_rmi4_f12_finger_data {
- unsigned char object_type_and_status;
- unsigned char x_lsb;
- unsigned char x_msb;
- unsigned char y_lsb;
- unsigned char y_msb;
- #ifdef REPORT_2D_Z
- unsigned char z;
- #endif
- #ifdef REPORT_2D_W
- unsigned char wx;
- unsigned char wy;
- #endif
- };
- struct synaptics_rmi4_f1a_query {
- union {
- struct {
- unsigned char max_button_count:3;
- unsigned char reserved:5;
- unsigned char has_general_control:1;
- unsigned char has_interrupt_enable:1;
- unsigned char has_multibutton_select:1;
- unsigned char has_tx_rx_map:1;
- unsigned char has_perbutton_threshold:1;
- unsigned char has_release_threshold:1;
- unsigned char has_strongestbtn_hysteresis:1;
- unsigned char has_filter_strength:1;
- } __packed;
- unsigned char data[2];
- };
- };
- struct synaptics_rmi4_f1a_control_0 {
- union {
- struct {
- unsigned char multibutton_report:2;
- unsigned char filter_mode:2;
- unsigned char reserved:4;
- } __packed;
- unsigned char data[1];
- };
- };
- struct synaptics_rmi4_f1a_control_3_4 {
- unsigned char transmitterbutton;
- unsigned char receiverbutton;
- };
- struct synaptics_rmi4_f1a_control {
- struct synaptics_rmi4_f1a_control_0 general_control;
- unsigned char *button_int_enable;
- unsigned char *multi_button;
- struct synaptics_rmi4_f1a_control_3_4 *electrode_map;
- unsigned char *button_threshold;
- unsigned char button_release_threshold;
- unsigned char strongest_button_hysteresis;
- unsigned char filter_strength;
- };
- struct synaptics_rmi4_f1a_handle {
- int button_bitmask_size;
- unsigned char button_count;
- unsigned char valid_button_count;
- unsigned char *button_data_buffer;
- unsigned char *button_map;
- struct synaptics_rmi4_f1a_query button_query;
- struct synaptics_rmi4_f1a_control button_control;
- };
- struct synaptics_rmi4_f34_ctrl_3 {
- union {
- struct {
- unsigned char fw_release_month;
- unsigned char fw_release_date;
- unsigned char fw_release_revision;
- unsigned char fw_release_version;
- };
- unsigned char data[4];
- };
- };
- struct synaptics_rmi4_f34_fn_ptr {
- int (*read)(struct synaptics_rmi4_data *rmi4_data, unsigned short addr,
- unsigned char *data, unsigned short length);
- int (*write)(struct synaptics_rmi4_data *rmi4_data, unsigned short addr,
- unsigned char *data, unsigned short length);
- int (*enable)(struct synaptics_rmi4_data *rmi4_data, bool enable);
- };
- struct synaptics_rmi4_f34_handle {
- unsigned char status;
- unsigned char cmd;
- unsigned short bootloaderid;
- unsigned short blocksize;
- unsigned short imageblockcount;
- unsigned short configblockcount;
- unsigned short blocknum;
- unsigned short query_base_addr;
- unsigned short control_base_addr;
- unsigned short data_base_addr;
- bool inflashprogmode;
- unsigned char intr_mask;
- struct mutex attn_mutex;
- struct synaptics_rmi4_f34_fn_ptr *fn_ptr;
- };
- #ifdef PROXIMITY
- struct synaptics_rmi4_f51_query {
- union {
- struct {
- unsigned char query_register_count;
- unsigned char data_register_count;
- unsigned char control_register_count;
- unsigned char command_register_count;
- unsigned char proximity_controls;
- };
- unsigned char data[5];
- };
- };
- struct synaptics_rmi4_f51_data {
- union {
- struct {
- unsigned char finger_hover_det:1;
- unsigned char air_swipe_det:1;
- unsigned char large_obj_det:1;
- unsigned char f1a_data0_b3:1;
- unsigned char hover_pinch_det:1;
- unsigned char f1a_data0_b5__7:3;
- unsigned char hover_finger_x_4__11;
- unsigned char hover_finger_y_4__11;
- unsigned char hover_finger_xy_0__3;
- unsigned char hover_finger_z;
- unsigned char air_swipe_dir_0:1;
- unsigned char air_swipe_dir_1:1;
- unsigned char f1a_data3_b2__4:3;
- unsigned char object_present:1;
- unsigned char large_obj_act:2;
- } __packed;
- unsigned char proximity_data[6];
- };
- #ifdef EDGE_SWIPE
- union {
- struct {
- unsigned char edge_swipe_x_lsb;
- unsigned char edge_swipe_x_msb;
- unsigned char edge_swipe_y_lsb;
- unsigned char edge_swipe_y_msb;
- unsigned char edge_swipe_z;
- unsigned char edge_swipe_wx;
- unsigned char edge_swipe_wy;
- unsigned char edge_swipe_mm;
- unsigned char edge_swipe_dg;
- } __packed;
- unsigned char edge_swipe_data[9];
- };
- #endif
- };
- #ifdef EDGE_SWIPE
- struct synaptics_rmi4_surface {
- int width_major;
- int palm;
- int angle;
- int wx;
- int wy;
- };
- #endif
- struct synaptics_rmi4_f51_handle {
- unsigned char proximity_enables;
- unsigned short proximity_enables_addr;
- unsigned char num_of_data_sources;
- #ifdef USE_CUSTOM_REZERO
- unsigned short proximity_custom_rezero_addr;
- #endif
- unsigned char proximity_controls;
- #ifdef EDGE_SWIPE
- struct synaptics_rmi4_surface surface_data;
- #endif
- struct synaptics_rmi4_data *rmi4_data;
- };
- #endif
- struct synaptics_rmi4_exp_fn {
- enum exp_fn fn_type;
- bool initialized;
- int (*func_init)(struct synaptics_rmi4_data *rmi4_data);
- void (*func_remove)(struct synaptics_rmi4_data *rmi4_data);
- void (*func_attn)(struct synaptics_rmi4_data *rmi4_data,
- unsigned char intr_mask);
- struct list_head link;
- };
- static struct device_attribute attrs[] = {
- #ifdef CONFIG_HAS_EARLYSUSPEND
- __ATTR(full_pm_cycle, (S_IRUGO | S_IWUSR | S_IWGRP),
- synaptics_rmi4_full_pm_cycle_show,
- synaptics_rmi4_full_pm_cycle_store),
- #endif
- #ifdef PROXIMITY
- __ATTR(proximity_enables, (S_IRUGO | S_IWUSR | S_IWGRP),
- synaptics_rmi4_f51_enables_show,
- synaptics_rmi4_f51_enables_store),
- #endif
- __ATTR(reset, S_IWUSR | S_IWGRP,
- synaptics_rmi4_show_error,
- synaptics_rmi4_f01_reset_store),
- __ATTR(productinfo, S_IRUGO,
- synaptics_rmi4_f01_productinfo_show,
- synaptics_rmi4_store_error),
- __ATTR(buildid, S_IRUGO,
- synaptics_rmi4_f01_buildid_show,
- synaptics_rmi4_store_error),
- __ATTR(flashprog, S_IRUGO,
- synaptics_rmi4_f01_flashprog_show,
- synaptics_rmi4_store_error),
- __ATTR(0dbutton, (S_IRUGO | S_IWUSR | S_IWGRP),
- synaptics_rmi4_0dbutton_show,
- synaptics_rmi4_0dbutton_store),
- };
- #if !defined(CONFIG_SEC_MELIUSCA_PROJECT)
- static struct synaptics_rmi4_platform_data rmi4_platformdata = {
- // .irq_type = IRQF_TRIGGER_FALLING,
- /*Direct IRQ for secure input*/
- // .irq_type = IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- // .gpio = GPIO_TOUCH_IRQ,
- .sensor_max_x = SYNAPTICS_MAX_X_SIZE,
- .sensor_max_y = SYNAPTICS_MAX_Y_SIZE,
- .max_touch_width = 28,
- /*.gpio_config = synaptics_gpio_setup,*/
- //.f1a_button_map = &tm1940_f1a_button_map,
- // .register_cb = synaptics_tsp_register_callback,
- .tsppwr_1p8_en = 480,
- .firmware_name = NULL,
- .fac_firmware_name = NULL,
- .num_of_rx = NUM_RX,
- .num_of_tx = NUM_TX,
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- .hsync_onoff = mdss_dsi_panel_hsync_onoff,
- #endif
- };
- #else
- static unsigned char tm1940_f1a_button_codes[] = {KEY_MENU, KEY_BACK};
- static struct synaptics_rmi_f1a_button_map tm1940_f1a_button_map = {
- .nbuttons = ARRAY_SIZE(tm1940_f1a_button_codes),
- .map = tm1940_f1a_button_codes,
- };
- static struct synaptics_rmi4_platform_data rmi4_platformdata = {
- // .irq_type = IRQF_TRIGGER_FALLING,
- /*Direct IRQ for secure input*/
- // .irq_type = IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- // .gpio = GPIO_TOUCH_IRQ,
- .sensor_max_x = SYNAPTICS_MAX_X_SIZE,
- .sensor_max_y = SYNAPTICS_MAX_Y_SIZE,
- .max_touch_width = 28,
- /*.gpio_config = synaptics_gpio_setup,*/
- .f1a_button_map = &tm1940_f1a_button_map,
- // .register_cb = synaptics_tsp_register_callback,
- .tsppwr_1p8_en = 480,
- .firmware_name = NULL,
- .fac_firmware_name = NULL,
- .num_of_rx = NUM_RX,
- .num_of_tx = NUM_TX,
- };
- #endif
- static int touch_sleep_time;
- extern int system_rev;
- static struct list_head exp_fn_list;
- #ifdef PROXIMITY
- static struct synaptics_rmi4_f51_handle *f51;
- #endif
- #ifdef CONFIG_OF
- static int synaptics_parse_dt(struct device *dev,
- struct synaptics_rmi4_power_data *pdata)
- {
- struct device_node *np = dev->of_node;
- /* reset, irq gpio info */
- pdata->vdd_io_1p8 = of_get_named_gpio(np, "synaptics,tsppwr_en", 0);
- pdata->tsp_int = of_get_named_gpio(np, "synaptics,irq-gpio", 0);
- pr_err("%s tsppwr_1p8_en= %d, tsp_int= %d\n", __func__,
- pdata->vdd_io_1p8, pdata->tsp_int);
- return 0;
- }
- #else
- static int synaptics_parse_dt(struct device *dev,
- struct synaptics_rmi4_power_data *pdata)
- {
- return -ENODEV;
- }
- #endif
- static void synaptics_request_gpio(struct synaptics_rmi4_power_data *pdata)
- {
- int ret;
- pr_info("[TSP] synaptics_request_gpio\n");
- ret = gpio_request(pdata->vdd_io_1p8, "synaptics,tsppwr_en");
- if (ret) {
- pr_err("[TSP]%s: unable to request vdd_io_1p8 [%d]\n",
- __func__, pdata->vdd_io_1p8);
- return;
- }
- }
- #ifdef CONFIG_HAS_EARLYSUSPEND
- static ssize_t synaptics_rmi4_full_pm_cycle_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%u\n",
- rmi4_data->full_pm_cycle);
- }
- static ssize_t synaptics_rmi4_full_pm_cycle_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
- {
- unsigned int input;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- if (sscanf(buf, "%u", &input) != 1)
- return -EINVAL;
- rmi4_data->full_pm_cycle = input > 0 ? 1 : 0;
- return count;
- }
- #endif
- #ifdef TSP_BOOSTER
- static void synaptics_change_dvfs_lock(struct work_struct *work)
- {
- struct synaptics_rmi4_data *rmi4_data =
- container_of(work,
- struct synaptics_rmi4_data, work_dvfs_chg.work);
- int retval = 0;
- mutex_lock(&rmi4_data->dvfs_lock);
- if (rmi4_data->dvfs_boost_mode == DVFS_STAGE_DUAL) {
- if (rmi4_data->stay_awake) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: do fw update, do not change cpu frequency.\n",
- __func__);
- } else {
- retval = set_freq_limit(DVFS_TOUCH_ID,
- MIN_TOUCH_LIMIT_SECOND);
- rmi4_data->dvfs_freq = MIN_TOUCH_LIMIT_SECOND;
- }
- } else if (rmi4_data->dvfs_boost_mode == DVFS_STAGE_SINGLE) {
- retval = set_freq_limit(DVFS_TOUCH_ID, -1);
- rmi4_data->dvfs_freq = -1;
- }
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: booster change failed(%d).\n",
- __func__, retval);
- mutex_unlock(&rmi4_data->dvfs_lock);
- }
- static void synaptics_set_dvfs_off(struct work_struct *work)
- {
- struct synaptics_rmi4_data *rmi4_data =
- container_of(work,
- struct synaptics_rmi4_data, work_dvfs_off.work);
- int retval;
- if (rmi4_data->stay_awake) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: do fw update, do not change cpu frequency.\n",
- __func__);
- } else {
- mutex_lock(&rmi4_data->dvfs_lock);
- retval = set_freq_limit(DVFS_TOUCH_ID, -1);
- rmi4_data->dvfs_freq = -1;
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: booster stop failed(%d).\n",
- __func__, retval);
- rmi4_data->dvfs_lock_status = false;
- mutex_unlock(&rmi4_data->dvfs_lock);
- }
- }
- static void synaptics_set_dvfs_lock(struct synaptics_rmi4_data *rmi4_data,
- int on)
- {
- int ret = 0;
- if (rmi4_data->dvfs_boost_mode == DVFS_STAGE_NONE) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: DVFS stage is none(%d)\n",
- __func__, rmi4_data->dvfs_boost_mode);
- return;
- }
- mutex_lock(&rmi4_data->dvfs_lock);
- if (on == 0) {
- if (rmi4_data->dvfs_lock_status) {
- schedule_delayed_work(&rmi4_data->work_dvfs_off,
- msecs_to_jiffies(TOUCH_BOOSTER_OFF_TIME));
- }
- } else if (on > 0) {
- cancel_delayed_work(&rmi4_data->work_dvfs_off);
- if (rmi4_data->dvfs_old_stauts != on) {
- cancel_delayed_work(&rmi4_data->work_dvfs_chg);
- if (1/*!rmi4_data->dvfs_lock_status*/) {
- if (rmi4_data->dvfs_freq != MIN_TOUCH_LIMIT) {
- ret = set_freq_limit(DVFS_TOUCH_ID,
- MIN_TOUCH_LIMIT);
- rmi4_data->dvfs_freq = MIN_TOUCH_LIMIT;
- if (ret < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: cpu first lock failed(%d)\n",
- __func__, ret);
- }
- schedule_delayed_work(&rmi4_data->work_dvfs_chg,
- msecs_to_jiffies(TOUCH_BOOSTER_CHG_TIME));
- rmi4_data->dvfs_lock_status = true;
- }
- }
- } else if (on < 0) {
- if (rmi4_data->dvfs_lock_status) {
- cancel_delayed_work(&rmi4_data->work_dvfs_off);
- cancel_delayed_work(&rmi4_data->work_dvfs_chg);
- schedule_work(&rmi4_data->work_dvfs_off.work);
- }
- }
- rmi4_data->dvfs_old_stauts = on;
- mutex_unlock(&rmi4_data->dvfs_lock);
- }
- static void synaptics_init_dvfs(struct synaptics_rmi4_data *rmi4_data)
- {
- mutex_init(&rmi4_data->dvfs_lock);
- rmi4_data->dvfs_boost_mode = DVFS_STAGE_DUAL;
- INIT_DELAYED_WORK(&rmi4_data->work_dvfs_off, synaptics_set_dvfs_off);
- INIT_DELAYED_WORK(&rmi4_data->work_dvfs_chg, synaptics_change_dvfs_lock);
- rmi4_data->dvfs_lock_status = false;
- }
- #endif
- #ifdef PROXIMITY
- static ssize_t synaptics_rmi4_f51_enables_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- if (!f51)
- return -ENODEV;
- return snprintf(buf, PAGE_SIZE, "0x%02x\n",
- f51->proximity_enables);
- }
- static ssize_t synaptics_rmi4_f51_enables_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
- {
- int retval;
- unsigned int input;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- if (!f51)
- return -ENODEV;
- if (sscanf(buf, "%x", &input) != 1)
- return -EINVAL;
- f51->proximity_enables = (unsigned char)input;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- f51->proximity_enables_addr,
- &f51->proximity_enables,
- sizeof(f51->proximity_enables));
- if (retval < 0) {
- dev_err(dev, "%s: Failed to write proximity enables, error = %d\n",
- __func__, retval);
- return retval;
- }
- return count;
- }
- #endif
- static ssize_t synaptics_rmi4_f01_reset_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
- {
- int retval;
- unsigned int reset;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- if (sscanf(buf, "%u", &reset) != 1)
- return -EINVAL;
- if (reset != 1)
- return -EINVAL;
- retval = synaptics_rmi4_reset_device(rmi4_data);
- if (retval < 0) {
- dev_err(dev,
- "%s: Failed to issue reset command, error = %d\n",
- __func__, retval);
- return retval;
- }
- return count;
- }
- static ssize_t synaptics_rmi4_f01_productinfo_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "0x%02x 0x%02x\n",
- (rmi4_data->rmi4_mod_info.product_info[0]),
- (rmi4_data->rmi4_mod_info.product_info[1]));
- }
- static ssize_t synaptics_rmi4_f01_buildid_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- unsigned int build_id;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- build_id = (unsigned int)rmi->build_id[0] +
- (unsigned int)rmi->build_id[1] * 0x100 +
- (unsigned int)rmi->build_id[2] * 0x10000;
- return snprintf(buf, PAGE_SIZE, "%u\n",
- build_id);
- }
- static ssize_t synaptics_rmi4_f01_flashprog_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- int retval;
- struct synaptics_rmi4_f01_device_status device_status;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr,
- device_status.data,
- sizeof(device_status.data));
- if (retval < 0) {
- dev_err(dev,
- "%s: Failed to read device status, error = %d\n",
- __func__, retval);
- return retval;
- }
- return snprintf(buf, PAGE_SIZE, "%u\n",
- device_status.flash_prog);
- }
- static ssize_t synaptics_rmi4_0dbutton_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%u\n",
- rmi4_data->button_0d_enabled);
- }
- static ssize_t synaptics_rmi4_0dbutton_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
- {
- int retval;
- unsigned int input;
- unsigned char ii;
- unsigned char intr_enable;
- struct synaptics_rmi4_fn *fhandler;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- if (sscanf(buf, "%u", &input) != 1)
- return -EINVAL;
- input = input > 0 ? 1 : 0;
- if (rmi4_data->button_0d_enabled == input)
- return count;
- if (list_empty(&rmi->support_fn_list))
- return -ENODEV;
- list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
- if (fhandler->fn_number == SYNAPTICS_RMI4_F1A) {
- ii = fhandler->intr_reg_num;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_ctrl_base_addr + 1 + ii,
- &intr_enable,
- sizeof(intr_enable));
- if (retval < 0)
- return retval;
- if (input == 1)
- intr_enable |= fhandler->intr_mask;
- else
- intr_enable &= ~fhandler->intr_mask;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_ctrl_base_addr + 1 + ii,
- &intr_enable,
- sizeof(intr_enable));
- if (retval < 0)
- return retval;
- }
- }
- rmi4_data->button_0d_enabled = input;
- return count;
- }
- /**
- * synaptics_rmi4_set_page()
- *
- * Called by synaptics_rmi4_i2c_read() and synaptics_rmi4_i2c_write().
- *
- * This function writes to the page select register to switch to the
- * assigned page.
- */
- static int synaptics_rmi4_set_page(struct synaptics_rmi4_data *rmi4_data,
- unsigned int address)
- {
- int retval = 0;
- unsigned char retry;
- unsigned char buf[PAGE_SELECT_LEN];
- unsigned char page;
- struct i2c_client *i2c = rmi4_data->i2c_client;
- page = ((address >> 8) & MASK_8BIT);
- if (page != rmi4_data->current_page) {
- buf[0] = MASK_8BIT;
- buf[1] = page;
- for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
- retval = i2c_master_send(i2c, buf, PAGE_SELECT_LEN);
- if (retval != PAGE_SELECT_LEN) {
- if((rmi4_data->tsp_probe != true)&&(retry>=1)){
- dev_err(&i2c->dev,
- "%s: TSP needs to reboot \n",__func__);
- retval = TSP_NEEDTO_REBOOT;
- return retval;
- }
- dev_err(&i2c->dev,
- "%s: I2C retry = %d, i2c_master_send retval = %d\n",
- __func__, retry + 1, retval);
- if (retval == 0)
- retval = -EAGAIN;
- msleep(20);
- } else {
- rmi4_data->current_page = page;
- break;
- }
- }
- } else {
- retval = PAGE_SELECT_LEN;
- }
- return retval;
- }
- /**
- * synaptics_rmi4_i2c_read()
- *
- * Called by various functions in this driver, and also exported to
- * other expansion Function modules such as rmi_dev.
- *
- * This function reads data of an arbitrary length from the sensor,
- * starting from an assigned register address of the sensor, via I2C
- * with a retry mechanism.
- */
- static int synaptics_rmi4_i2c_read(struct synaptics_rmi4_data *rmi4_data,
- unsigned short addr, unsigned char *data, unsigned short length)
- {
- int retval;
- unsigned char retry;
- unsigned char buf;
- struct i2c_msg msg[] = {
- {
- .addr = rmi4_data->i2c_client->addr,
- .flags = 0,
- .len = 1,
- .buf = &buf,
- },
- {
- .addr = rmi4_data->i2c_client->addr,
- .flags = I2C_M_RD,
- .len = length,
- .buf = data,
- },
- };
- buf = addr & MASK_8BIT;
- mutex_lock(&(rmi4_data->rmi4_io_ctrl_mutex));
- if (rmi4_data->touch_stopped) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: Sensor stopped\n",
- __func__);
- retval = 0;
- goto exit;
- }
- retval = synaptics_rmi4_set_page(rmi4_data, addr);
- if (retval != PAGE_SELECT_LEN)
- goto exit;
- for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
- if (i2c_transfer(rmi4_data->i2c_client->adapter, msg, 2) == 2) {
- retval = length;
- break;
- }
- dev_err(&rmi4_data->i2c_client->dev, "%s: I2C retry %d\n",
- __func__, retry + 1);
- msleep(20);
- }
- if (retry == SYN_I2C_RETRY_TIMES) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: I2C read over retry limit\n",
- __func__);
- retval = -EIO;
- }
- exit:
- mutex_unlock(&(rmi4_data->rmi4_io_ctrl_mutex));
- return retval;
- }
- /**
- * synaptics_rmi4_i2c_write()
- *
- * Called by various functions in this driver, and also exported to
- * other expansion Function modules such as rmi_dev.
- *
- * This function writes data of an arbitrary length to the sensor,
- * starting from an assigned register address of the sensor, via I2C with
- * a retry mechanism.
- */
- static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
- unsigned short addr, unsigned char *data, unsigned short length)
- {
- int retval;
- unsigned char retry;
- unsigned char buf[length + 1];
- struct i2c_msg msg[] = {
- {
- .addr = rmi4_data->i2c_client->addr,
- .flags = 0,
- .len = length + 1,
- .buf = buf,
- }
- };
- mutex_lock(&(rmi4_data->rmi4_io_ctrl_mutex));
- if (rmi4_data->touch_stopped) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: Sensor stopped\n",
- __func__);
- retval = 0;
- goto exit;
- }
- retval = synaptics_rmi4_set_page(rmi4_data, addr);
- if (retval != PAGE_SELECT_LEN)
- goto exit;
- buf[0] = addr & MASK_8BIT;
- memcpy(&buf[1], &data[0], length);
- for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
- if (i2c_transfer(rmi4_data->i2c_client->adapter, msg, 1) == 1) {
- retval = length;
- break;
- }
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: I2C retry %d\n",
- __func__, retry + 1);
- msleep(20);
- }
- if (retry == SYN_I2C_RETRY_TIMES) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: I2C write over retry limit\n",
- __func__);
- retval = -EIO;
- }
- exit:
- mutex_unlock(&(rmi4_data->rmi4_io_ctrl_mutex));
- return retval;
- }
- #ifdef TSP_PATTERN_TRACKING_METHOD
- static void clear_tcount(void)
- {
- int i;
- for(i=0;i<MAX_GHOSTCHECK_FINGER;i++){
- tcount_finger[i] = 0;
- touchbx[i] = 0;
- touchby[i] = 0;
- }
- }
-
- static int diff_two_point(int x, int y, int oldx, int oldy)
- {
- int diffx,diffy;
- int distance;
- diffx = x-oldx;
- diffy = y-oldy;
- distance = abs(diffx) + abs(diffy);
- if(distance < PATTERN_TRACKING_DISTANCE) return 1;
- else return 0;
- }
- static bool IsEdgeArea(int x, int y)
- {
- bool fEdge = false;
- if((x <= MIN_X_EDGE)||(x >= MAX_X_EDGE)||(y <= MIN_Y_EDGE)||(y >= MAX_Y_EDGE))fEdge = true;
- return fEdge;
- }
- /* To do forced calibration when ghost touch occured at the same point
- for several second. Xtopher */
- static bool tsp_pattern_tracking(int fingerindex, int x, int y, bool movecheck)
- {
- int max_ghosttouch_th = MAX_GHOSTTOUCH_COUNT;
- bool ghosttouch = false;
- #ifdef PATTERN_TRACKING_FOR_FULLSCREEN
- if(!IsEdgeArea(x,y)){
- if(movecheck == true) return ghosttouch;
- max_ghosttouch_th = MAX_GHOSTTOUCH_COUNT*2;
- }
- #else
- if(!IsEdgeArea(x,y)) return ghosttouch;
- #endif
- //if((touchbx[i] == x)&&(touchby[i] == y))
- if(diff_two_point(x,y, touchbx[fingerindex], touchby[fingerindex]))
- {
- tcount_finger[fingerindex]++;
- }
- else
- {
- tcount_finger[fingerindex] = 0;
- }
- touchbx[fingerindex] = x;
- touchby[fingerindex] = y;
- if(tcount_finger[fingerindex]>= max_ghosttouch_th){
- clear_tcount();
- ghosttouch = true;
- return ghosttouch;
- }
- return ghosttouch;
- }
- #endif
- /**
- * synaptics_rmi4_f11_abs_report()
- *
- * Called by synaptics_rmi4_report_touch() when valid Function $11
- * finger data has been detected.
- *
- * This function reads the Function $11 data registers, determines the
- * status of each finger supported by the Function, processes any
- * necessary coordinate manipulation, reports the finger data to
- * the input subsystem, and returns the number of fingers detected.
- */
- static int synaptics_rmi4_f11_abs_report(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- unsigned char touch_count = 0; /* number of touch points */
- unsigned char reg_index;
- unsigned char finger;
- unsigned char fingers_supported;
- unsigned char num_of_finger_status_regs;
- unsigned char finger_shift;
- unsigned char finger_status;
- unsigned char data_reg_blk_size;
- unsigned char finger_status_reg[3];
- unsigned char data[F11_STD_DATA_LEN];
- unsigned short data_addr;
- unsigned short data_offset;
- int x;
- int y;
- int wx;
- int wy;
- /*
- * The number of finger status registers is determined by the
- * maximum number of fingers supported - 2 bits per finger. So
- * the number of finger status registers to read is:
- * register_count = ceil(max_num_of_fingers / 4)
- */
- fingers_supported = fhandler->num_of_data_points;
- num_of_finger_status_regs = (fingers_supported + 3) / 4;
- data_addr = fhandler->full_addr.data_base;
- data_reg_blk_size = fhandler->size_of_data_register_block;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_addr,
- finger_status_reg,
- num_of_finger_status_regs);
- if (retval < 0)
- return 0;
- for (finger = 0; finger < fingers_supported; finger++) {
- reg_index = finger / 4;
- finger_shift = (finger % 4) * 2;
- finger_status = (finger_status_reg[reg_index] >> finger_shift)
- & MASK_2BIT;
- /*
- * Each 2-bit finger status field represents the following:
- * 00 = finger not present
- * 01 = finger present and data accurate
- * 10 = finger present but data may be inaccurate
- * 11 = reserved
- */
- #ifdef TYPE_B_PROTOCOL
- input_mt_slot(rmi4_data->input_dev, finger);
- input_mt_report_slot_state(rmi4_data->input_dev,
- MT_TOOL_FINGER, finger_status);
- #endif
- if (finger_status) {
- data_offset = data_addr +
- num_of_finger_status_regs +
- (finger * data_reg_blk_size);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_offset,
- data,
- data_reg_blk_size);
- if (retval < 0)
- return 0;
- x = (data[0] << 4) | (data[2] & MASK_4BIT);
- y = (data[1] << 4) | ((data[2] >> 4) & MASK_4BIT);
- wx = (data[3] & MASK_4BIT);
- wy = (data[3] >> 4) & MASK_4BIT;
- if (rmi4_data->board->x_flip)
- x = rmi4_data->sensor_max_x - x;
- if (rmi4_data->board->y_flip)
- y = rmi4_data->sensor_max_y - y;
- input_report_key(rmi4_data->input_dev,
- BTN_TOUCH, 1);
- input_report_key(rmi4_data->input_dev,
- BTN_TOOL_FINGER, 1);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_X, x);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_Y, y);
- #ifdef REPORT_2D_W
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_TOUCH_MAJOR, max(wx, wy));
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_TOUCH_MINOR, min(wx, wy));
- #endif
- #ifndef TYPE_B_PROTOCOL
- input_mt_sync(rmi4_data->input_dev);
- #endif
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Finger %d:\n"
- "status = 0x%02x\n"
- "x = %d\n"
- "y = %d\n"
- "wx = %d\n"
- "wy = %d\n",
- __func__, finger,
- finger_status,
- x, y, wx, wy);
- touch_count++;
- }
- }
- #ifndef TYPE_B_PROTOCOL
- if (touch_count == 0)
- input_mt_sync(rmi4_data->input_dev);
- #endif
- input_sync(rmi4_data->input_dev);
- return touch_count;
- }
- /**
- * synaptics_rmi4_f12_abs_report()
- *
- * Called by synaptics_rmi4_report_touch() when valid Function $12
- * finger data has been detected.
- *
- * This function reads the Function $12 data registers, determines the
- * status of each finger supported by the Function, processes any
- * necessary coordinate manipulation, reports the finger data to
- * the input subsystem, and returns the number of fingers detected.
- */
- static int synaptics_rmi4_f12_abs_report(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- unsigned char touch_count = 0; /* number of touch points */
- unsigned char finger;
- unsigned char fingers_supported;
- unsigned char finger_status;
- unsigned short data_addr;
- int x;
- int y;
- int wx;
- int wy;
- struct synaptics_rmi4_f12_finger_data *data;
- struct synaptics_rmi4_f12_finger_data *finger_data;
- fingers_supported = fhandler->num_of_data_points;
- data_addr = fhandler->full_addr.data_base;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_addr + fhandler->data1_offset,
- (unsigned char *)fhandler->data,
- fhandler->data_size);
- if (retval < 0)
- return 0;
- data = (struct synaptics_rmi4_f12_finger_data *)fhandler->data;
- for (finger = 0; finger < fingers_supported; finger++) {
- finger_data = data + finger;
- finger_status = finger_data->object_type_and_status;
- if (finger_status) {
- if ((finger_data->wx == 0) && (finger_data->wy == 0))
- continue;
- }
- /*
- * Each 3-bit finger status field represents the following:
- * 000 = finger not present
- * 001 = finger present and data accurate
- * 010 = finger present but data may be inaccurate
- * 011 = palm
- * 110 = glove touch
- */
- #ifdef TYPE_B_PROTOCOL
- input_mt_slot(rmi4_data->input_dev, finger);
- input_mt_report_slot_state(rmi4_data->input_dev,
- MT_TOOL_FINGER, finger_status);
- #endif
- if (finger_status) {
- #ifdef CONFIG_GLOVE_TOUCH
- if ((finger_status == 0x06) &&
- !rmi4_data->touchkey_glove_mode_status) {
- rmi4_data->touchkey_glove_mode_status = true;
- input_report_switch(rmi4_data->input_dev,
- SW_GLOVE, true);
- } else if ((finger_status != 0x06) &&
- rmi4_data->touchkey_glove_mode_status) {
- rmi4_data->touchkey_glove_mode_status = false;
- input_report_switch(rmi4_data->input_dev,
- SW_GLOVE, false);
- }
- #endif
- x = (finger_data->x_msb << 8) | (finger_data->x_lsb);
- y = (finger_data->y_msb << 8) | (finger_data->y_lsb);
- #ifdef REPORT_2D_W
- wx = finger_data->wx;
- wy = finger_data->wy;
- #ifdef EDGE_SWIPE
- if (f51) {
- if ((f51->proximity_controls & HAS_EDGE_SWIPE)
- && f51->surface_data.palm) {
- wx = f51->surface_data.wx;
- wy = f51->surface_data.wy;
- }
- }
- #endif
- #endif
- if (rmi4_data->board->x_flip)
- x = rmi4_data->sensor_max_x - x;
- if (rmi4_data->board->y_flip)
- y = rmi4_data->sensor_max_y - y;
- input_report_key(rmi4_data->input_dev,
- BTN_TOUCH, 1);
- input_report_key(rmi4_data->input_dev,
- BTN_TOOL_FINGER, 1);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_X, x);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_Y, y);
- #ifdef REPORT_2D_W
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_TOUCH_MAJOR, max(wx, wy));
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_TOUCH_MINOR, min(wx, wy));
- #endif
- #ifdef EDGE_SWIPE
- if (f51) {
- if (f51->proximity_controls & HAS_EDGE_SWIPE) {
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_WIDTH_MAJOR, f51->surface_data.width_major);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_PALM, f51->surface_data.palm);
- }
- }
- #endif
- #ifndef TYPE_B_PROTOCOL
- input_mt_sync(rmi4_data->input_dev);
- #endif
- if (!rmi4_data->finger[finger].state) {
- #ifdef TSP_PATTERN_TRACKING_METHOD
- /* Check hopping on almost fixed point */
- if(tsp_pattern_tracking(finger,x,y,false)){
- dev_err(&rmi4_data->i2c_client->dev,
- "Sunflower-Hopping (Pattern Tracking)\n");
- cancel_delayed_work(&rmi4_data->reboot_work);
- schedule_delayed_work(&rmi4_data->reboot_work,
- msecs_to_jiffies(TSP_REBOOT_PENDING_TIME*6)); /* 300msec*/
- touch_count = 0;
- return touch_count;
- }
- #endif
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- dev_info(&rmi4_data->i2c_client->dev, "[%d][P] 0x%02x, x = %d, y = %d, wx = %d, wy = %d\n",
- finger, finger_status, x, y, wx, wy);
- #else
- dev_info(&rmi4_data->i2c_client->dev, "[%d][P] 0x%02x\n",
- finger, finger_status);
- #endif
- } else {
- rmi4_data->finger[finger].mcount++;
-
- #ifdef TSP_PATTERN_TRACKING_METHOD
- /* Check staying finger at one point */
- if((rmi4_data->finger[finger].mcount%MOVE_COUNT_TH) == 0){
- if(tsp_pattern_tracking(finger,x,y,true)){
- dev_err(&rmi4_data->i2c_client->dev,
- "Sunflower-Fixed (Pattern Tracking)\n");
- cancel_delayed_work(&rmi4_data->reboot_work);
- schedule_delayed_work(&rmi4_data->reboot_work,
- msecs_to_jiffies(TSP_REBOOT_PENDING_TIME*6)); /* 300msec*/
- touch_count = 0;
- return touch_count;
- }
- }
- #endif
- }
- touch_count++;
- }
- if (rmi4_data->finger[finger].state && !finger_status) {
- #ifdef CONFIG_GLOVE_TOUCH
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- /* TODO : Remove version information when H/W dose not changed */
- dev_info(&rmi4_data->i2c_client->dev, "[%d][R] 0x%02x M[%d], Ver[%02X%02X%02X%02X]\n",
- finger, finger_status, rmi4_data->finger[finger].mcount,
- rmi4_data->ic_revision_of_ic, rmi4_data->panel_revision,
- rmi4_data->fw_version_of_ic, rmi4_data->glove_mode_enables);
- #else
- dev_info(&rmi4_data->i2c_client->dev, "[%d][R] 0x%02x M[%d], Ver[%02X%02X%02X%02X]\n",
- finger, finger_status, rmi4_data->finger[finger].mcount,
- rmi4_data->ic_revision_of_ic, rmi4_data->panel_revision,
- rmi4_data->fw_version_of_ic, rmi4_data->glove_mode_enables);
- #endif
- #else //CONFIG_GLOVE_TOUCH
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- /* TODO : Remove version information when H/W dose not changed */
- dev_info(&rmi4_data->i2c_client->dev, "[%d][R] 0x%02x M[%d], Ver[%02X%02X%02X]\n",
- finger, finger_status, rmi4_data->finger[finger].mcount,
- rmi4_data->ic_revision_of_ic, rmi4_data->panel_revision,
- rmi4_data->fw_version_of_ic);
- #else
- dev_info(&rmi4_data->i2c_client->dev, "[%d][R] 0x%02x M[%d], Ver[%02X%02X%02X]\n",
- finger, finger_status, rmi4_data->finger[finger].mcount,
- rmi4_data->ic_revision_of_ic, rmi4_data->panel_revision,
- rmi4_data->fw_version_of_ic);
- #endif
- #endif//CONFIG_GLOVE_TOUCH
- rmi4_data->finger[finger].mcount = 0;
- }
- rmi4_data->finger[finger].state = finger_status;
- }
- if (touch_count == 0) {
- /* Clear BTN_TOUCH when All touch are released */
- input_report_key(rmi4_data->input_dev,
- BTN_TOUCH, 0);
- #ifndef TYPE_B_PROTOCOL
- input_mt_sync(rmi4_data->input_dev);
- #endif
- }
- input_sync(rmi4_data->input_dev);
- #ifdef TSP_BOOSTER
- if (touch_count)
- synaptics_set_dvfs_lock(rmi4_data, touch_count);
- else
- synaptics_set_dvfs_lock(rmi4_data, 0);
- #endif
- return touch_count;
- }
- static void synaptics_rmi4_f1a_report(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- unsigned char touch_count = 0;
- unsigned char button;
- unsigned char index;
- unsigned char shift;
- unsigned char status;
- unsigned char *data;
- unsigned short data_addr = fhandler->full_addr.data_base;
- struct synaptics_rmi4_f1a_handle *f1a = fhandler->data;
- static unsigned char do_once = 1;
- static bool current_status[MAX_NUMBER_OF_BUTTONS];
- #ifdef NO_0D_WHILE_2D
- static bool before_2d_status[MAX_NUMBER_OF_BUTTONS];
- static bool while_2d_status[MAX_NUMBER_OF_BUTTONS];
- #endif
- if (do_once) {
- memset(current_status, 0, sizeof(current_status));
- #ifdef NO_0D_WHILE_2D
- memset(before_2d_status, 0, sizeof(before_2d_status));
- memset(while_2d_status, 0, sizeof(while_2d_status));
- #endif
- do_once = 0;
- }
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_addr,
- f1a->button_data_buffer,
- f1a->button_bitmask_size);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read button data registers\n",
- __func__);
- return;
- }
- data = f1a->button_data_buffer;
- for (button = 0; button < f1a->valid_button_count; button++) {
- index = button / 8;
- shift = button % 8;
- status = ((data[index] >> shift) & MASK_1BIT);
- if (current_status[button] == status)
- continue;
- else
- current_status[button] = status;
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Button %d (code %d) ->%d\n",
- __func__, button,
- f1a->button_map[button],
- status);
- #ifdef NO_0D_WHILE_2D
- if (rmi4_data->fingers_on_2d == false) {
- if (status == 1) {
- before_2d_status[button] = 1;
- } else {
- if (while_2d_status[button] == 1) {
- while_2d_status[button] = 0;
- continue;
- } else {
- before_2d_status[button] = 0;
- }
- }
- touch_count++;
- input_report_key(rmi4_data->input_dev,
- f1a->button_map[button],
- status);
- } else {
- if (before_2d_status[button] == 1) {
- before_2d_status[button] = 0;
- touch_count++;
- input_report_key(rmi4_data->input_dev,
- f1a->button_map[button],
- status);
- } else {
- if (status == 1)
- while_2d_status[button] = 1;
- else
- while_2d_status[button] = 0;
- }
- }
- #else
- touch_count++;
- input_report_key(rmi4_data->input_dev,
- f1a->button_map[button],
- status);
- #endif
- }
- if (touch_count)
- input_sync(rmi4_data->input_dev);
- return;
- }
- #ifdef PROXIMITY
- #ifdef EDGE_SWIPE
- static int synaptics_rmi4_f51_edge_swipe(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- unsigned short data_base_addr;
- struct synaptics_rmi4_f51_data *data;
- data_base_addr = fhandler->full_addr.data_base;
- data = (struct synaptics_rmi4_f51_data *)fhandler->data;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_base_addr + EDGE_SWIPE_DATA_OFFSET,
- data->edge_swipe_data,
- sizeof(data->edge_swipe_data));
- if (retval < 0)
- return retval;
- if (!f51)
- return -ENODEV;
- if (data->edge_swipe_dg >= 90 && data->edge_swipe_dg <= 180)
- #if defined(CONFIG_MACH_JACTIVESKT)
- f51->surface_data.angle = data->edge_swipe_dg - 90;
- #else
- f51->surface_data.angle = data->edge_swipe_dg - 180;
- #endif
- else if (data->edge_swipe_dg < 90)
- #if defined(CONFIG_MACH_JACTIVESKT)
- f51->surface_data.angle = 90 - data->edge_swipe_dg;
- #else
- f51->surface_data.angle = data->edge_swipe_dg;
- #endif
- else
- dev_err(&rmi4_data->i2c_client->dev, "Skip wrong edge swipe angle [%d]\n",
- data->edge_swipe_dg);
- f51->surface_data.width_major = data->edge_swipe_mm;
- f51->surface_data.wx = data->edge_swipe_wx;
- f51->surface_data.wy = data->edge_swipe_wy;
- f51->surface_data.palm = data->edge_swipe_z;
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: edge_data : x[%d], y[%d], z[%d] ,wx[%d], wy[%d], area[%d], angle[%d][%d]\n", __func__,
- data->edge_swipe_x_msb << 8 | data->edge_swipe_x_lsb,
- data->edge_swipe_y_msb << 8 | data->edge_swipe_y_lsb,
- data->edge_swipe_z, data->edge_swipe_wx, data->edge_swipe_wy,
- data->edge_swipe_mm, data->edge_swipe_dg, f51->surface_data.angle);
- return retval;
- }
- #endif
- static void synaptics_rmi4_f51_report(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- unsigned short data_base_addr;
- int x;
- int y;
- int z;
- struct synaptics_rmi4_f51_data *data;
- #ifdef EDGE_SWIPE
- /* Read edge swipe data */
- if (f51->proximity_controls & HAS_EDGE_SWIPE) {
- retval = synaptics_rmi4_f51_edge_swipe(rmi4_data, fhandler);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read edge swipe data\n",
- __func__);
- return;
- }
- }
- #endif
- data_base_addr = fhandler->full_addr.data_base;
- data = (struct synaptics_rmi4_f51_data *)fhandler->data;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- data_base_addr,
- data->proximity_data,
- sizeof(data->proximity_data));
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read proximity data registers\n",
- __func__);
- return;
- }
- if (data->proximity_data[0] == 0x00)
- return;
- if (data->finger_hover_det && (data->hover_finger_z > 0)) {
- x = (data->hover_finger_x_4__11 << 4) |
- (data->hover_finger_xy_0__3 & 0x0f);
- y = (data->hover_finger_y_4__11 << 4) |
- (data->hover_finger_xy_0__3 >> 4);
- z = HOVER_Z_MAX - data->hover_finger_z;
- #ifdef TYPE_B_PROTOCOL
- input_mt_slot(rmi4_data->input_dev, 0);
- input_mt_report_slot_state(rmi4_data->input_dev,
- MT_TOOL_FINGER, 1);
- #endif
- input_report_key(rmi4_data->input_dev,
- BTN_TOUCH, 0);
- input_report_key(rmi4_data->input_dev,
- BTN_TOOL_FINGER, 1);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_X, x);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_POSITION_Y, y);
- input_report_abs(rmi4_data->input_dev,
- ABS_MT_DISTANCE, z);
- #ifndef TYPE_B_PROTOCOL
- input_mt_sync(rmi4_data->input_dev);
- #endif
- input_sync(rmi4_data->input_dev);
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Hover finger:\n"
- "x = %d\n"
- "y = %d\n"
- "z = %d\n",
- __func__, x, y, z);
- rmi4_data->f51_finger = true;
- rmi4_data->fingers_on_2d = false;
- synaptics_rmi4_f51_finger_timer((unsigned long)rmi4_data);
- }
- if (data->air_swipe_det) {
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Swipe direction 0 = %d\n",
- __func__, data->air_swipe_dir_0);
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Swipe direction 1 = %d\n",
- __func__, data->air_swipe_dir_1);
- }
- if (data->large_obj_det) {
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Large object activity = %d\n",
- __func__, data->large_obj_act);
- }
- /*
- if (data->hover_pinch_det) {
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Hover pinch direction = %d\n",
- __func__, data->hover_pinch_dir);
- }
- */
- if (data->object_present) {
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Object presence detected\n",
- __func__);
- }
- return;
- }
- #endif
- /**
- * synaptics_rmi4_report_touch()
- *
- * Called by synaptics_rmi4_sensor_report().
- *
- * This function calls the appropriate finger data reporting function
- * based on the function handler it receives and returns the number of
- * fingers detected.
- */
- static void synaptics_rmi4_report_touch(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- unsigned char touch_count_2d;
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Function %02x reporting\n",
- __func__, fhandler->fn_number);
- switch (fhandler->fn_number) {
- case SYNAPTICS_RMI4_F11:
- touch_count_2d = synaptics_rmi4_f11_abs_report(rmi4_data,
- fhandler);
- if (touch_count_2d)
- rmi4_data->fingers_on_2d = true;
- else
- rmi4_data->fingers_on_2d = false;
- break;
- case SYNAPTICS_RMI4_F12:
- touch_count_2d = synaptics_rmi4_f12_abs_report(rmi4_data,
- fhandler);
- if (touch_count_2d)
- rmi4_data->fingers_on_2d = true;
- else
- rmi4_data->fingers_on_2d = false;
- break;
- case SYNAPTICS_RMI4_F1A:
- synaptics_rmi4_f1a_report(rmi4_data, fhandler);
- break;
- #ifdef PROXIMITY
- case SYNAPTICS_RMI4_F51:
- synaptics_rmi4_f51_report(rmi4_data, fhandler);
- break;
- #endif
- default:
- break;
- }
- return;
- }
- /**
- * synaptics_rmi4_sensor_report()
- *
- * Called by synaptics_rmi4_irq().
- *
- * This function determines the interrupt source(s) from the sensor
- * and calls synaptics_rmi4_report_touch() with the appropriate
- * function handler for each function with valid data inputs.
- */
- static int synaptics_rmi4_sensor_report(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char data[MAX_INTR_REGISTERS + 1];
- unsigned char *intr = &data[1];
- struct synaptics_rmi4_f01_device_status status;
- struct synaptics_rmi4_fn *fhandler;
- struct synaptics_rmi4_exp_fn *exp_fhandler;
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- /*
- * Get interrupt status information from F01 Data1 register to
- * determine the source(s) that are flagging the interrupt.
- */
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr,
- data,
- rmi4_data->num_of_intr_regs + 1);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read interrupt status\n",
- __func__);
- return retval;
- }
- status.data[0] = data[0];
- if (status.unconfigured) {
- if (rmi4_data->doing_reflash) {
- dev_err(&rmi4_data->i2c_client->dev,
- "Spontaneous reset detected during reflash.\n");
- return 0;
- }
- dev_info(&rmi4_data->i2c_client->dev,
- "Spontaneous reset detected\n");
- retval = synaptics_rmi4_reinit_device(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to reinit device\n",
- __func__);
- }
- return 0;
- }
- /*
- * Traverse the function handler list and service the source(s)
- * of the interrupt accordingly.
- */
- if (!list_empty(&rmi->support_fn_list)) {
- list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
- if (fhandler->num_of_data_sources) {
- if (fhandler->intr_mask &
- intr[fhandler->intr_reg_num]) {
- synaptics_rmi4_report_touch(rmi4_data,
- fhandler);
- }
- }
- }
- }
- if (!list_empty(&exp_fn_list)) {
- list_for_each_entry(exp_fhandler, &exp_fn_list, link) {
- if (exp_fhandler->func_attn != NULL)
- exp_fhandler->func_attn(rmi4_data, intr[0]);
- }
- }
- return 0;
- }
- /**
- * synaptics_rmi4_irq()
- *
- * Called by the kernel when an interrupt occurs (when the sensor
- * asserts the attention irq).
- *
- * This function is the ISR thread and handles the acquisition
- * and the reporting of finger data when the presence of fingers
- * is detected.
- */
- static irqreturn_t synaptics_rmi4_irq(int irq, void *data)
- {
- int retval;
- struct synaptics_rmi4_data *rmi4_data = data;
- do {
- retval = synaptics_rmi4_sensor_report(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to read",
- __func__);
- goto out;
- }
- if (!rmi4_data->touch_stopped)
- goto out;
- } while (!gpio_get_value(rmi4_data->irq));
- out:
- return IRQ_HANDLED;
- }
- /**
- * synaptics_rmi4_irq_enable()
- *
- * Called by synaptics_rmi4_probe() and the power management functions
- * in this driver and also exported to other expansion Function modules
- * such as rmi_dev.
- *
- * This function handles the enabling and disabling of the attention
- * irq including the setting up of the ISR thread.
- */
- static int synaptics_rmi4_irq_enable(struct synaptics_rmi4_data *rmi4_data,
- bool enable)
- {
- int retval = 0;
- unsigned char intr_status;
- if (enable) {
- if (rmi4_data->irq_enabled)
- return retval;
- /* Clear interrupts first */
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr + 1,
- &intr_status,
- rmi4_data->num_of_intr_regs);
- if (retval < 0)
- return retval;
- retval = request_threaded_irq(rmi4_data->irq, NULL,
- synaptics_rmi4_irq, IRQF_TRIGGER_FALLING,
- DRIVER_NAME, rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to create irq thread\n",
- __func__);
- return retval;
- }
- rmi4_data->irq_enabled = true;
- } else {
- if (rmi4_data->irq_enabled) {
- disable_irq(rmi4_data->irq);
- free_irq(rmi4_data->irq, rmi4_data);
- rmi4_data->irq_enabled = false;
- }
- }
- return retval;
- }
- /**
- * synaptics_rmi4_f11_init()
- *
- * Called by synaptics_rmi4_query_device().
- *
- * This funtion parses information from the Function 11 registers
- * and determines the number of fingers supported, x and y data ranges,
- * offset to the associated interrupt status register, interrupt bit
- * mask, and gathers finger data acquisition capabilities from the query
- * registers.
- */
- static int synaptics_rmi4_f11_init(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler,
- struct synaptics_rmi4_fn_desc *fd,
- unsigned int intr_count)
- {
- int retval;
- unsigned char ii;
- unsigned char intr_offset;
- unsigned char abs_data_size;
- unsigned char abs_data_blk_size;
- unsigned char query[F11_STD_QUERY_LEN];
- unsigned char control[F11_STD_CTRL_LEN];
- fhandler->fn_number = fd->fn_number;
- fhandler->num_of_data_sources = fd->intr_src_count;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base,
- query,
- sizeof(query));
- if (retval < 0)
- return retval;
- /* Maximum number of fingers supported */
- if ((query[1] & MASK_3BIT) <= 4)
- fhandler->num_of_data_points = (query[1] & MASK_3BIT) + 1;
- else if ((query[1] & MASK_3BIT) == 5)
- fhandler->num_of_data_points = 10;
- rmi4_data->num_of_fingers = fhandler->num_of_data_points;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.ctrl_base,
- control,
- sizeof(control));
- if (retval < 0)
- return retval;
- /* Maximum x and y */
- rmi4_data->sensor_max_x = ((control[6] & MASK_8BIT) << 0) |
- ((control[7] & MASK_4BIT) << 8);
- rmi4_data->sensor_max_y = ((control[8] & MASK_8BIT) << 0) |
- ((control[9] & MASK_4BIT) << 8);
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Function %02x max x = %d max y = %d\n",
- __func__, fhandler->fn_number,
- rmi4_data->sensor_max_x,
- rmi4_data->sensor_max_y);
- rmi4_data->max_touch_width = MAX_F11_TOUCH_WIDTH;
- fhandler->intr_reg_num = (intr_count + 7) / 8;
- if (fhandler->intr_reg_num != 0)
- fhandler->intr_reg_num -= 1;
- /* Set an enable bit for each data source */
- intr_offset = intr_count % 8;
- fhandler->intr_mask = 0;
- for (ii = intr_offset;
- ii < ((fd->intr_src_count & MASK_3BIT) +
- intr_offset);
- ii++)
- fhandler->intr_mask |= 1 << ii;
- abs_data_size = query[5] & MASK_2BIT;
- abs_data_blk_size = 3 + (2 * (abs_data_size == 0 ? 1 : 0));
- fhandler->size_of_data_register_block = abs_data_blk_size;
- fhandler->data = NULL;
- return retval;
- }
- #ifdef CONFIG_GLOVE_TOUCH
- int synaptics_rmi4_glove_mode_enables(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- if (GLOVE_FEATURE_EN != rmi4_data->glove_mode_feature) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Ver[%02X%02X%02X] FW does not support glove mode %02X\n",
- __func__, rmi4_data->panel_revision, rmi4_data->ic_revision_of_ic,
- rmi4_data->fw_version_of_ic, rmi4_data->glove_mode_feature);
- return 0;
- }
- if (rmi4_data->touch_stopped)
- return 0;
- dev_info(&rmi4_data->i2c_client->dev, "%s: [%02X]: %s\n",
- __func__, rmi4_data->glove_mode_enables,
- (rmi4_data->glove_mode_enables == 0x07) ? "fast glove & clear cover enable" :
- (rmi4_data->glove_mode_enables == 0x06) ? "fast glove & flip cover enable" :
- (rmi4_data->glove_mode_enables == 0x05) ? "only fast glove enable" :
- (rmi4_data->glove_mode_enables == 0x03) ? "only clear cover enable" :
- (rmi4_data->glove_mode_enables == 0x02) ? "only flip cover enable" :
- (rmi4_data->glove_mode_enables == 0x01) ? "only glove enable" : "glove disable");
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->glove_mode_enables_addr,
- &rmi4_data->glove_mode_enables,
- sizeof(rmi4_data->glove_mode_enables));
- if (retval < 0)
- return retval;
- return 0;
- }
- #endif
- static int synaptics_rmi4_f12_set_enables(struct synaptics_rmi4_data *rmi4_data,
- unsigned short address)
- {
- int retval;
- unsigned char enable_mask;
- static unsigned short ctrl_28_address;
- if (address)
- ctrl_28_address = address;
- enable_mask = RPT_DEFAULT;
- #ifdef REPORT_2D_Z
- enable_mask |= RPT_Z;
- #endif
- #ifdef REPORT_2D_W
- enable_mask |= (RPT_WX | RPT_WY);
- #endif
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- ctrl_28_address,
- &enable_mask,
- sizeof(enable_mask));
- if (retval < 0)
- return retval;
- return retval;
- }
- /**
- * synaptics_rmi4_f12_init()
- *
- * Called by synaptics_rmi4_query_device().
- *
- * This funtion parses information from the Function 12 registers and
- * determines the number of fingers supported, offset to the data1
- * register, x and y data ranges, offset to the associated interrupt
- * status register, interrupt bit mask, and allocates memory resources
- * for finger data acquisition.
- */
- static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler,
- struct synaptics_rmi4_fn_desc *fd,
- unsigned int intr_count)
- {
- int retval;
- unsigned char ii;
- unsigned char intr_offset;
- unsigned char size_of_2d_data;
- unsigned char ctrl_8_offset;
- unsigned char ctrl_9_offset;
- unsigned char ctrl_23_offset;
- unsigned char ctrl_26_offset;
- unsigned char ctrl_28_offset;
- unsigned char fingers_to_support = F12_FINGERS_TO_SUPPORT;
- struct synaptics_rmi4_f12_query_5 query_5;
- struct synaptics_rmi4_f12_query_8 query_8;
- struct synaptics_rmi4_f12_ctrl_8 ctrl_8;
- struct synaptics_rmi4_f12_ctrl_9 ctrl_9;
- struct synaptics_rmi4_f12_ctrl_23 ctrl_23;
- #ifdef CONFIG_GLOVE_TOUCH
- struct synaptics_rmi4_f12_ctrl_26 ctrl_26;
- #endif
- fhandler->fn_number = fd->fn_number;
- fhandler->num_of_data_sources = fd->intr_src_count;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base + 5,
- query_5.data,
- sizeof(query_5.data));
- if (retval < 0)
- return retval;
- ctrl_8_offset = query_5.ctrl0_is_present +
- query_5.ctrl1_is_present +
- query_5.ctrl2_is_present +
- query_5.ctrl3_is_present +
- query_5.ctrl4_is_present +
- query_5.ctrl5_is_present +
- query_5.ctrl6_is_present +
- query_5.ctrl7_is_present;
- ctrl_9_offset = ctrl_8_offset +
- query_5.ctrl8_is_present;
- ctrl_23_offset = ctrl_9_offset +
- query_5.ctrl9_is_present +
- query_5.ctrl10_is_present +
- query_5.ctrl11_is_present +
- query_5.ctrl12_is_present +
- query_5.ctrl13_is_present +
- query_5.ctrl14_is_present +
- query_5.ctrl15_is_present +
- query_5.ctrl16_is_present +
- query_5.ctrl17_is_present +
- query_5.ctrl18_is_present +
- query_5.ctrl19_is_present +
- query_5.ctrl20_is_present +
- query_5.ctrl21_is_present +
- query_5.ctrl22_is_present;
- ctrl_26_offset = ctrl_23_offset +
- query_5.ctrl23_is_present +
- query_5.ctrl24_is_present +
- query_5.ctrl25_is_present;
- ctrl_28_offset = ctrl_26_offset +
- query_5.ctrl26_is_present +
- query_5.ctrl27_is_present;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.ctrl_base + ctrl_23_offset,
- ctrl_23.data,
- sizeof(ctrl_23.data));
- if (retval < 0)
- return retval;
- /* Maximum number of fingers supported */
- fhandler->num_of_data_points = min(ctrl_23.max_reported_objects,
- fingers_to_support);
- rmi4_data->num_of_fingers = fhandler->num_of_data_points;
- retval = synaptics_rmi4_f12_set_enables(rmi4_data,
- fhandler->full_addr.ctrl_base + ctrl_28_offset);
- if (retval < 0)
- return retval;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base + 8,
- query_8.data,
- sizeof(query_8.data));
- if (retval < 0)
- return retval;
- /* Determine the presence of the Data0 register */
- fhandler->data1_offset = query_8.data0_is_present;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.ctrl_base + ctrl_8_offset,
- ctrl_8.data,
- sizeof(ctrl_8.data));
- if (retval < 0)
- return retval;
- /* Maximum x and y */
- rmi4_data->sensor_max_x =
- ((unsigned short)ctrl_8.max_x_coord_lsb << 0) |
- ((unsigned short)ctrl_8.max_x_coord_msb << 8);
- rmi4_data->sensor_max_y =
- ((unsigned short)ctrl_8.max_y_coord_lsb << 0) |
- ((unsigned short)ctrl_8.max_y_coord_msb << 8);
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Function %02x max x = %d max y = %d\n",
- __func__, fhandler->fn_number,
- rmi4_data->sensor_max_x,
- rmi4_data->sensor_max_y);
- if (!rmi4_data->board->num_of_rx && !rmi4_data->board->num_of_tx) {
- rmi4_data->num_of_rx = ctrl_8.num_of_rx;
- rmi4_data->num_of_tx = ctrl_8.num_of_tx;
- rmi4_data->max_touch_width = max(rmi4_data->num_of_rx,
- rmi4_data->num_of_tx);
- rmi4_data->num_of_node = ctrl_8.num_of_rx * ctrl_8.num_of_tx;
- } else {
- rmi4_data->num_of_rx = rmi4_data->board->num_of_rx;
- rmi4_data->num_of_tx = rmi4_data->board->num_of_tx;
- rmi4_data->max_touch_width = max(rmi4_data->num_of_rx,
- rmi4_data->num_of_tx);
- rmi4_data->num_of_node = rmi4_data->num_of_rx * rmi4_data->num_of_tx;
- }
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.ctrl_base + ctrl_9_offset,
- ctrl_9.data,
- sizeof(ctrl_9.data));
- if (retval < 0)
- return retval;
- rmi4_data->touch_threshold = (int)ctrl_9.touch_threshold;
- rmi4_data->gloved_sensitivity = (int)ctrl_9.gloved_finger;
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: %02x num_Rx:%d num_Tx:%d, node:%d, threshold:%d, gloved sensitivity:%x\n",
- __func__, fhandler->fn_number,
- rmi4_data->num_of_rx, rmi4_data->num_of_tx,
- rmi4_data->num_of_node, rmi4_data->touch_threshold,
- rmi4_data->gloved_sensitivity);
- fhandler->intr_reg_num = (intr_count + 7) / 8;
- if (fhandler->intr_reg_num != 0)
- fhandler->intr_reg_num -= 1;
- /* Set an enable bit for each data source */
- intr_offset = intr_count % 8;
- fhandler->intr_mask = 0;
- for (ii = intr_offset;
- ii < ((fd->intr_src_count & MASK_3BIT) +
- intr_offset);
- ii++)
- fhandler->intr_mask |= 1 << ii;
- size_of_2d_data = sizeof(struct synaptics_rmi4_f12_finger_data);
- /* Allocate memory for finger data storage space */
- fhandler->data_size = fhandler->num_of_data_points * size_of_2d_data;
- fhandler->data = kzalloc(fhandler->data_size, GFP_KERNEL);
- #ifdef CONFIG_GLOVE_TOUCH
- rmi4_data->glove_mode_enables_addr = fhandler->full_addr.ctrl_base +
- ctrl_26_offset;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base + 10,
- ctrl_26.data,
- sizeof(ctrl_26.data));
- if (retval < 0)
- return retval;
- rmi4_data->glove_mode_feature = ctrl_26.glove_feature_enable;
- synaptics_rmi4_glove_mode_enables(rmi4_data);
- #endif
- return retval;
- }
- static int synaptics_rmi4_f1a_alloc_mem(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- struct synaptics_rmi4_f1a_handle *f1a;
- f1a = kzalloc(sizeof(*f1a), GFP_KERNEL);
- if (!f1a) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc mem for function handle\n",
- __func__);
- return -ENOMEM;
- }
- fhandler->data = (void *)f1a;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base,
- f1a->button_query.data,
- sizeof(f1a->button_query.data));
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read query registers\n",
- __func__);
- return retval;
- }
- f1a->button_count = f1a->button_query.max_button_count + 1;
- f1a->button_bitmask_size = (f1a->button_count + 7) / 8;
- f1a->button_data_buffer = kcalloc(f1a->button_bitmask_size,
- sizeof(*(f1a->button_data_buffer)), GFP_KERNEL);
- if (!f1a->button_data_buffer) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc mem for data buffer\n",
- __func__);
- return -ENOMEM;
- }
- f1a->button_map = kcalloc(f1a->button_count,
- sizeof(*(f1a->button_map)), GFP_KERNEL);
- if (!f1a->button_map) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc mem for button map\n",
- __func__);
- return -ENOMEM;
- }
- return 0;
- }
- static int synaptics_rmi4_f1a_button_map(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- unsigned char ii;
- struct synaptics_rmi4_f1a_handle *f1a = fhandler->data;
- const struct synaptics_rmi4_platform_data *pdata = rmi4_data->board;
- if (!pdata->f1a_button_map) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: f1a_button_map is NULL in board file\n",
- __func__);
- return -ENODEV;
- } else if (!pdata->f1a_button_map->map) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Button map is missing in board file\n",
- __func__);
- return -ENODEV;
- } else {
- if (pdata->f1a_button_map->nbuttons != f1a->button_count) {
- f1a->valid_button_count = min(f1a->button_count,
- pdata->f1a_button_map->nbuttons);
- } else {
- f1a->valid_button_count = f1a->button_count;
- }
- for (ii = 0; ii < f1a->valid_button_count; ii++)
- f1a->button_map[ii] = pdata->f1a_button_map->map[ii];
- }
- return 0;
- }
- static void synaptics_rmi4_f1a_kfree(struct synaptics_rmi4_fn *fhandler)
- {
- struct synaptics_rmi4_f1a_handle *f1a = fhandler->data;
- if (f1a) {
- kfree(f1a->button_data_buffer);
- kfree(f1a->button_map);
- kfree(f1a);
- fhandler->data = NULL;
- }
- return;
- }
- static int synaptics_rmi4_f1a_init(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler,
- struct synaptics_rmi4_fn_desc *fd,
- unsigned int intr_count)
- {
- int retval;
- unsigned char ii;
- unsigned short intr_offset;
- fhandler->fn_number = fd->fn_number;
- fhandler->num_of_data_sources = fd->intr_src_count;
- fhandler->intr_reg_num = (intr_count + 7) / 8;
- if (fhandler->intr_reg_num != 0)
- fhandler->intr_reg_num -= 1;
- /* Set an enable bit for each data source */
- intr_offset = intr_count % 8;
- fhandler->intr_mask = 0;
- for (ii = intr_offset;
- ii < ((fd->intr_src_count & MASK_3BIT) +
- intr_offset);
- ii++)
- fhandler->intr_mask |= 1 << ii;
- retval = synaptics_rmi4_f1a_alloc_mem(rmi4_data, fhandler);
- if (retval < 0)
- goto error_exit;
- retval = synaptics_rmi4_f1a_button_map(rmi4_data, fhandler);
- if (retval < 0)
- goto error_exit;
- rmi4_data->button_0d_enabled = 1;
- return 0;
- error_exit:
- synaptics_rmi4_f1a_kfree(fhandler);
- return retval;
- }
- static int synaptics_rmi4_f34_read_version(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler)
- {
- int retval;
- struct synaptics_rmi4_f34_ctrl_3 ctrl_3;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.ctrl_base,
- ctrl_3.data,
- sizeof(ctrl_3.data));
- if (retval < 0)
- return retval;
- dev_info(&rmi4_data->i2c_client->dev, "%s: [IC] [date, revision, version, panel] [%02d/%02d, 0x%02X, 0x%02X, 0x%02X]\n",
- __func__, ctrl_3.fw_release_month, ctrl_3.fw_release_date,
- ctrl_3.fw_release_revision, ctrl_3.fw_release_version,
- rmi4_data->panel_revision);
- rmi4_data->fw_release_date_of_ic =
- (ctrl_3.fw_release_month << 8) | ctrl_3.fw_release_date;
- rmi4_data->ic_revision_of_ic = ctrl_3.fw_release_revision;
- rmi4_data->fw_version_of_ic = ctrl_3.fw_release_version;
- return retval;
- }
- static int synaptics_rmi4_f34_init(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler,
- struct synaptics_rmi4_fn_desc *fd,
- unsigned int intr_count)
- {
- int retval;
- fhandler->fn_number = fd->fn_number;
- fhandler->num_of_data_sources = fd->intr_src_count;
- retval = synaptics_rmi4_f34_read_version(rmi4_data, fhandler);
- if (retval < 0)
- return retval;
- fhandler->data = NULL;
- return retval;
- }
- #ifdef PROXIMITY
- #ifdef USE_CUSTOM_REZERO
- static int synaptics_rmi4_f51_set_custom_rezero(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char custom_rezero;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- f51->proximity_custom_rezero_addr,
- &custom_rezero, sizeof(custom_rezero));
- if (F51_VERSION == f51->num_of_data_sources)
- custom_rezero |= 0x34;
- else
- custom_rezero |= 0x01;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- f51->proximity_custom_rezero_addr,
- &custom_rezero, sizeof(custom_rezero));
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: fail to write custom rezero\n",
- __func__);
- return retval;
- }
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- return 0;
- }
- static void synaptics_rmi4_rezero_work(struct work_struct *work)
- {
- int retval;
- struct synaptics_rmi4_data *rmi4_data =
- container_of(work, struct synaptics_rmi4_data,
- rezero_work.work);
- /* Do not check hover enable status, because rezero bit does not effect
- * to doze(mutual only) mdoe.
- */
- retval = synaptics_rmi4_f51_set_custom_rezero(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to rezero device\n", __func__);
- }
- #endif
- int synaptics_proximity_no_sleep_set(bool enables)
- {
- int retval;
- unsigned char no_sleep = 0;
- if (!f51)
- return -ENODEV;
- retval = synaptics_rmi4_i2c_read(f51->rmi4_data,
- f51->rmi4_data->f01_ctrl_base_addr,
- &no_sleep,
- sizeof(no_sleep));
- if (retval <= 0)
- dev_err(&f51->rmi4_data->i2c_client->dev, "%s: fail to read no_sleep[ret:%d]\n",
- __func__, retval);
- if (enables)
- no_sleep |= NO_SLEEP_ON;
- else
- no_sleep &= ~(NO_SLEEP_ON);
- retval = synaptics_rmi4_i2c_write(f51->rmi4_data,
- f51->rmi4_data->f01_ctrl_base_addr,
- &no_sleep,
- sizeof(no_sleep));
- if (retval <= 0)
- dev_err(&f51->rmi4_data->i2c_client->dev, "%s: fail to set no_sleep[%X][ret:%d]\n",
- __func__, no_sleep, retval);
- return retval;
- }
- EXPORT_SYMBOL(synaptics_proximity_no_sleep_set);
- static int synaptics_rmi4_f51_set_enables(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- dev_info(&rmi4_data->i2c_client->dev, "%s: %s[0x%x]\n", __func__,
- (f51->proximity_enables & FINGER_HOVER_EN) ? "enable" : "disable", f51->proximity_enables);
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- f51->proximity_enables_addr,
- &f51->proximity_enables,
- sizeof(f51->proximity_enables));
- if (retval < 0)
- return retval;
- return 0;
- }
- static int synaptics_rmi4_f51_set_init(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- dev_info(&rmi4_data->i2c_client->dev, "%s: proximity controls:[0X%02X]\n",
- __func__, f51->proximity_controls);
- #ifdef USE_CUSTOM_REZERO
- retval = synaptics_rmi4_f51_set_custom_rezero(rmi4_data);
- if (retval < 0)
- return retval;
- /*
- * Need 100msec to finish acquiring for hover baseline
- * Synaptics recommend that do not send a hover disable cmd during 100msec.
- * (after send custom rezero cmd on IC on time)
- * Under current driver, this delay does not affect to wakeup latency.
- * But it will affect to latency, below proximity enable code can move into delay work.
- */
- msleep(SYNAPTICS_REZERO_TIME);
- #endif
- retval = synaptics_rmi4_f51_set_enables(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to set enable\n", __func__);
- }
- return retval;
- }
- static int synaptics_rmi4_f51_init(struct synaptics_rmi4_data *rmi4_data,
- struct synaptics_rmi4_fn *fhandler,
- struct synaptics_rmi4_fn_desc *fd,
- unsigned int intr_count)
- {
- int retval;
- unsigned char ii;
- unsigned short intr_offset;
- struct synaptics_rmi4_f51_data *data_register;
- struct synaptics_rmi4_f51_query query_register;
- fhandler->fn_number = fd->fn_number;
- fhandler->num_of_data_sources = fd->intr_src_count;
- fhandler->intr_reg_num = (intr_count + 7) / 8;
- if (fhandler->intr_reg_num != 0)
- fhandler->intr_reg_num -= 1;
- /* Set an enable bit for each data source */
- intr_offset = intr_count % 8;
- fhandler->intr_mask = 0;
- for (ii = intr_offset;
- ii < ((fd->intr_src_count & MASK_3BIT) + intr_offset);
- ii++)
- fhandler->intr_mask |= 1 << ii;
- fhandler->data_size = sizeof(*data_register);
- data_register = kzalloc(fhandler->data_size, GFP_KERNEL);
- fhandler->data = (void *)data_register;
- f51 = kzalloc(sizeof(*f51), GFP_KERNEL);
- f51->rmi4_data = rmi4_data;
- if (F51_VERSION == fhandler->num_of_data_sources) {
- f51->num_of_data_sources = fhandler->num_of_data_sources;
- f51->proximity_enables = AIR_SWIPE_EN | SLEEP_PROXIMITY;
- f51->proximity_enables_addr = fhandler->full_addr.ctrl_base +
- F51_PROXIMITY_ENABLES_OFFSET;
- #ifdef USE_CUSTOM_REZERO
- f51->proximity_custom_rezero_addr = fhandler->full_addr.ctrl_base +
- F51_GENERAL_CONTROL_OFFSET;
- #endif
- } else {
- f51->proximity_enables = PROXIMITY_DEFAULT;
- f51->proximity_enables_addr = fhandler->full_addr.ctrl_base +
- F51_CTRL54_OFFSET;
- #ifdef USE_CUSTOM_REZERO
- f51->proximity_custom_rezero_addr = fhandler->full_addr.ctrl_base +
- F51_CTRL78_OFFSET;
- #endif
- }
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- fhandler->full_addr.query_base,
- query_register.data,
- sizeof(query_register));
- if (retval < 0)
- return retval;
- /* Save proximity controls(query 4 register) to get which functions
- * are supported by firmware.
- */
- f51->proximity_controls = query_register.proximity_controls;
- retval = synaptics_rmi4_f51_set_init(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: fail proximity set init\n",
- __func__);
- return retval;
- }
- return 0;
- }
- int synaptics_rmi4_proximity_enables(unsigned char enables)
- {
- int retval;
- if (!f51)
- return -ENODEV;
- if (F51_VERSION == f51->num_of_data_sources) {
- if (enables)
- f51->proximity_enables = AIR_SWIPE_EN | FINGER_HOVER_EN;
- else
- f51->proximity_enables = AIR_SWIPE_EN | SLEEP_PROXIMITY;
- } else {
- if (enables)
- f51->proximity_enables = PROXIMITY_ENABLE;
- else
- f51->proximity_enables = PROXIMITY_DEFAULT;
- }
- if (f51->rmi4_data->touch_stopped)
- return 0;
- retval = synaptics_rmi4_f51_set_enables(f51->rmi4_data);
- if (retval < 0)
- return retval;
- #ifdef USE_CUSTOM_REZERO
- cancel_delayed_work(&f51->rmi4_data->rezero_work);
- if (f51->proximity_enables & FINGER_HOVER_EN)
- schedule_delayed_work(&f51->rmi4_data->rezero_work,
- msecs_to_jiffies(SYNAPTICS_REZERO_TIME*3)); /* 300msec*/
- #endif
- return 0;
- }
- EXPORT_SYMBOL(synaptics_rmi4_proximity_enables);
- #endif
- static int synaptics_rmi4_check_status(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- int timeout = CHECK_STATUS_TIMEOUT_MS;
- unsigned char data;
- struct synaptics_rmi4_f01_device_status status;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr,
- status.data,
- sizeof(status.data));
- if (retval < 0)
- return retval;
- dev_info(&rmi4_data->i2c_client->dev, "%s: Device status[0x%02x] status.code[%d]\n",
- __func__, status.data[0], status.status_code);
- while (status.status_code == STATUS_CRC_IN_PROGRESS) {
- if (timeout > 0)
- msleep(20);
- else
- return -1;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr,
- status.data,
- sizeof(status.data));
- if (retval < 0)
- return retval;
- timeout -= 20;
- }
- if (status.flash_prog == 1) {
- rmi4_data->flash_prog_mode = true;
- dev_info(&rmi4_data->i2c_client->dev, "%s: In flash prog mode, status = 0x%02x\n",
- __func__, status.status_code);
- } else {
- rmi4_data->flash_prog_mode = false;
- }
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_data_base_addr,
- &data,
- sizeof(data));
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to read interrupt status\n",
- __func__);
- return retval;
- }
- return 0;
- }
- static void synaptics_rmi4_set_configured(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char device_ctrl;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to set configured\n",
- __func__);
- return;
- }
- device_ctrl |= CONFIGURED;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to set configured\n",
- __func__);
- }
- return;
- }
- static int synaptics_rmi4_alloc_fh(struct synaptics_rmi4_fn **fhandler,
- struct synaptics_rmi4_fn_desc *rmi_fd, int page_number)
- {
- *fhandler = kzalloc(sizeof(**fhandler), GFP_KERNEL);
- if (!(*fhandler))
- return -ENOMEM;
- (*fhandler)->full_addr.data_base =
- (rmi_fd->data_base_addr |
- (page_number << 8));
- (*fhandler)->full_addr.ctrl_base =
- (rmi_fd->ctrl_base_addr |
- (page_number << 8));
- (*fhandler)->full_addr.cmd_base =
- (rmi_fd->cmd_base_addr |
- (page_number << 8));
- (*fhandler)->full_addr.query_base =
- (rmi_fd->query_base_addr |
- (page_number << 8));
- return 0;
- }
- /**
- * synaptics_rmi4_query_device()
- *
- * Called by synaptics_rmi4_probe().
- *
- * This funtion scans the page description table, records the offsets
- * to the register types of Function $01, sets up the function handlers
- * for Function $11 and Function $12, determines the number of interrupt
- * sources from the sensor, adds valid Functions with data inputs to the
- * Function linked list, parses information from the query registers of
- * Function $01, and enables the interrupt sources from the valid Functions
- * with data inputs.
- */
- static int synaptics_rmi4_query_device(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char ii = 0;
- unsigned char page_number;
- unsigned char intr_count = 0;
- unsigned char f01_query[F01_STD_QUERY_LEN];
- unsigned short pdt_entry_addr;
- unsigned short intr_addr;
- struct synaptics_rmi4_fn_desc rmi_fd;
- struct synaptics_rmi4_fn *fhandler;
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- INIT_LIST_HEAD(&rmi->support_fn_list);
- /* Scan the page description tables of the pages to service */
- for (page_number = 0; page_number < PAGES_TO_SERVICE; page_number++) {
- for (pdt_entry_addr = PDT_START; pdt_entry_addr > PDT_END;
- pdt_entry_addr -= PDT_ENTRY_SIZE) {
- pdt_entry_addr |= (page_number << 8);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- pdt_entry_addr,
- (unsigned char *)&rmi_fd,
- sizeof(rmi_fd));
- if (retval < 0)
- return retval;
- fhandler = NULL;
- if (rmi_fd.fn_number == 0) {
- dev_dbg(&rmi4_data->i2c_client->dev,
- "%s: Reached end of PDT\n",
- __func__);
- break;
- }
- /* Display function description infomation */
- dev_dbg(&rmi4_data->i2c_client->dev, "%s: F%02x found (page %d): INT_SRC[%02X] BASE_ADDRS[%02X,%02X,%02X,%02x]\n",
- __func__, rmi_fd.fn_number, page_number,
- rmi_fd.intr_src_count, rmi_fd.data_base_addr,
- rmi_fd.ctrl_base_addr, rmi_fd.cmd_base_addr,
- rmi_fd.query_base_addr);
- switch (rmi_fd.fn_number) {
- case SYNAPTICS_RMI4_F01:
- rmi4_data->f01_query_base_addr =
- rmi_fd.query_base_addr;
- rmi4_data->f01_ctrl_base_addr =
- rmi_fd.ctrl_base_addr;
- rmi4_data->f01_data_base_addr =
- rmi_fd.data_base_addr;
- rmi4_data->f01_cmd_base_addr =
- rmi_fd.cmd_base_addr;
- retval = synaptics_rmi4_check_status(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to check status\n",
- __func__);
- return retval;
- }
- if (rmi4_data->flash_prog_mode)
- goto flash_prog_mode;
- break;
- case SYNAPTICS_RMI4_F11:
- if (rmi_fd.intr_src_count == 0)
- break;
- retval = synaptics_rmi4_alloc_fh(&fhandler,
- &rmi_fd, page_number);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc for F%d\n",
- __func__,
- rmi_fd.fn_number);
- return retval;
- }
- retval = synaptics_rmi4_f11_init(rmi4_data,
- fhandler, &rmi_fd, intr_count);
- if (retval < 0)
- return retval;
- break;
- case SYNAPTICS_RMI4_F12:
- if (rmi_fd.intr_src_count == 0)
- break;
- retval = synaptics_rmi4_alloc_fh(&fhandler,
- &rmi_fd, page_number);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc for F%d\n",
- __func__,
- rmi_fd.fn_number);
- return retval;
- }
- retval = synaptics_rmi4_f12_init(rmi4_data,
- fhandler, &rmi_fd, intr_count);
- if (retval < 0)
- return retval;
- break;
- case SYNAPTICS_RMI4_F1A:
- if (rmi_fd.intr_src_count == 0)
- break;
- retval = synaptics_rmi4_alloc_fh(&fhandler,
- &rmi_fd, page_number);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc for F%d\n",
- __func__,
- rmi_fd.fn_number);
- return retval;
- }
- retval = synaptics_rmi4_f1a_init(rmi4_data,
- fhandler, &rmi_fd, intr_count);
- if (retval < 0)
- return retval;
- break;
- case SYNAPTICS_RMI4_F34:
- if (rmi_fd.intr_src_count == 0)
- break;
- retval = synaptics_rmi4_alloc_fh(&fhandler,
- &rmi_fd, page_number);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc for F%d\n",
- __func__,
- rmi_fd.fn_number);
- return retval;
- }
- retval = synaptics_rmi4_f34_init(rmi4_data,
- fhandler, &rmi_fd, intr_count);
- if (retval < 0)
- return retval;
- break;
- #ifdef PROXIMITY
- case SYNAPTICS_RMI4_F51:
- if (rmi_fd.intr_src_count == 0)
- break;
- retval = synaptics_rmi4_alloc_fh(&fhandler,
- &rmi_fd, page_number);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to alloc for F%d\n",
- __func__,
- rmi_fd.fn_number);
- return retval;
- }
- retval = synaptics_rmi4_f51_init(rmi4_data,
- fhandler, &rmi_fd, intr_count);
- if (retval < 0)
- return retval;
- break;
- #endif
- }
- /* Accumulate the interrupt count */
- intr_count += (rmi_fd.intr_src_count & MASK_3BIT);
- if (fhandler && rmi_fd.intr_src_count) {
- list_add_tail(&fhandler->link,
- &rmi->support_fn_list);
- }
- }
- }
- flash_prog_mode:
- rmi4_data->num_of_intr_regs = (intr_count + 7) / 8;
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: Number of interrupt registers = %d sum of intr_count = %d\n",
- __func__, rmi4_data->num_of_intr_regs, intr_count);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_query_base_addr,
- f01_query,
- sizeof(f01_query));
- if (retval < 0)
- return retval;
- /* RMI Version 4.0 currently supported */
- rmi->version_major = 4;
- rmi->version_minor = 0;
- rmi->manufacturer_id = f01_query[0];
- rmi->product_props = f01_query[1];
- rmi->product_info[0] = f01_query[2] & MASK_7BIT;
- rmi->product_info[1] = f01_query[3] & MASK_7BIT;
- rmi->date_code[0] = f01_query[4] & MASK_5BIT;
- rmi->date_code[1] = f01_query[5] & MASK_4BIT;
- rmi->date_code[2] = f01_query[6] & MASK_5BIT;
- rmi->tester_id = ((f01_query[7] & MASK_7BIT) << 8) |
- (f01_query[8] & MASK_7BIT);
- rmi->serial_number = ((f01_query[9] & MASK_7BIT) << 8) |
- (f01_query[10] & MASK_7BIT);
- memcpy(rmi->product_id_string, &f01_query[11], 10);
- if (rmi->manufacturer_id != 1) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Non-Synaptics device found, manufacturer ID = %d\n",
- __func__, rmi->manufacturer_id);
- }
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_query_base_addr + F01_BUID_ID_OFFSET,
- rmi->build_id,
- sizeof(rmi->build_id));
- if (retval < 0)
- return retval;
- memset(rmi4_data->intr_mask, 0x00, sizeof(rmi4_data->intr_mask));
- /*
- * Map out the interrupt bit masks for the interrupt sources
- * from the registered function handlers.
- */
- if (!list_empty(&rmi->support_fn_list)) {
- list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
- if (fhandler->num_of_data_sources) {
- rmi4_data->intr_mask[fhandler->intr_reg_num] |=
- fhandler->intr_mask;
- }
- /* To display each fhandler data */
- dev_info(&rmi4_data->i2c_client->dev, "%s: F%02x : NUM_SOURCE[%02X] NUM_INT_REG[%02X] INT_MASK[%02X]\n",
- __func__, fhandler->fn_number,
- fhandler->num_of_data_sources, fhandler->intr_reg_num,
- fhandler->intr_mask);
- }
- }
- /* Enable the interrupt sources */
- for (ii = 0; ii < rmi4_data->num_of_intr_regs; ii++) {
- if (rmi4_data->intr_mask[ii] != 0x00) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: Interrupt enable mask %d = 0x%02x\n",
- __func__, ii, rmi4_data->intr_mask[ii]);
- intr_addr = rmi4_data->f01_ctrl_base_addr + 1 + ii;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- intr_addr,
- &(rmi4_data->intr_mask[ii]),
- sizeof(rmi4_data->intr_mask[ii]));
- if (retval < 0)
- return retval;
- }
- }
- synaptics_rmi4_set_configured(rmi4_data);
- return 0;
- }
- static void synaptics_rmi4_release_support_fn(struct synaptics_rmi4_data *rmi4_data)
- {
- struct synaptics_rmi4_fn *fhandler, *n;
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- if (list_empty(&rmi->support_fn_list)) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: support_fn_list is empty\n",
- __func__);
- goto out;
- }
- list_for_each_entry_safe(fhandler, n, &rmi->support_fn_list, link) {
- dev_dbg(&rmi4_data->i2c_client->dev, "%s: fn_number = %x\n",
- __func__, fhandler->fn_number);
- if (fhandler->fn_number == SYNAPTICS_RMI4_F1A)
- synaptics_rmi4_f1a_kfree(fhandler);
- else
- kfree(fhandler->data);
- kfree(fhandler);
- }
- out:
- #ifdef PROXIMITY
- kfree(f51);
- f51 = NULL;
- #endif
- }
- static int synaptics_rmi4_set_input_device
- (struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char ii;
- struct synaptics_rmi4_f1a_handle *f1a;
- struct synaptics_rmi4_fn *fhandler;
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- rmi4_data->input_dev = input_allocate_device();
- if (rmi4_data->input_dev == NULL) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to allocate input device\n",
- __func__);
- retval = -ENOMEM;
- goto err_input_device;
- }
- retval = synaptics_rmi4_query_device(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to query device\n",
- __func__);
- goto err_query_device;
- }
- rmi4_data->input_dev->name = "sec_touchscreen";
- rmi4_data->input_dev->id.bustype = BUS_I2C;
- rmi4_data->input_dev->dev.parent = &rmi4_data->i2c_client->dev;
- #ifdef USE_OPEN_CLOSE
- rmi4_data->input_dev->open = synaptics_rmi4_input_open;
- rmi4_data->input_dev->close = synaptics_rmi4_input_close;
- #endif
- input_set_drvdata(rmi4_data->input_dev, rmi4_data);
- #ifdef CONFIG_GLOVE_TOUCH
- input_set_capability(rmi4_data->input_dev, EV_SW, SW_GLOVE);
- #endif
- set_bit(EV_SYN, rmi4_data->input_dev->evbit);
- set_bit(EV_KEY, rmi4_data->input_dev->evbit);
- set_bit(EV_ABS, rmi4_data->input_dev->evbit);
- #if defined(CONFIG_SEC_MELIUSCA_PROJECT)
- set_bit(EV_LED, rmi4_data->input_dev->evbit);
- set_bit(LED_MISC, rmi4_data->input_dev->ledbit);
- #endif
- set_bit(BTN_TOUCH, rmi4_data->input_dev->keybit);
- set_bit(BTN_TOOL_FINGER, rmi4_data->input_dev->keybit);
- #ifdef INPUT_PROP_DIRECT
- set_bit(INPUT_PROP_DIRECT, rmi4_data->input_dev->propbit);
- #endif
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_POSITION_X, 0,
- rmi4_data->board->sensor_max_x, 0, 0);
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_POSITION_Y, 0,
- rmi4_data->board->sensor_max_y, 0, 0);
- #ifdef REPORT_2D_W
- #ifdef EDGE_SWIPE
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_TOUCH_MAJOR, 0,
- EDGE_SWIPE_WIDTH_MAX, 0, 0);
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_TOUCH_MINOR, 0,
- EDGE_SWIPE_WIDTH_MAX, 0, 0);
- #else
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_TOUCH_MAJOR, 0,
- rmi4_data->board->max_touch_width, 0, 0);
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_TOUCH_MINOR, 0,
- rmi4_data->board->max_touch_width, 0, 0);
- #endif
- #endif
- #ifdef PROXIMITY
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_DISTANCE, 0,
- HOVER_Z_MAX, 0, 0);
- #ifdef EDGE_SWIPE
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_WIDTH_MAJOR, 0,
- EDGE_SWIPE_WIDTH_MAX, 0, 0);
- input_set_abs_params(rmi4_data->input_dev,
- ABS_MT_PALM, 0,
- EDGE_SWIPE_PALM_MAX, 0, 0);
- #endif
- setup_timer(&rmi4_data->f51_finger_timer,
- synaptics_rmi4_f51_finger_timer,
- (unsigned long)rmi4_data);
- #endif
- #ifdef TYPE_B_PROTOCOL
- input_mt_init_slots(rmi4_data->input_dev,
- rmi4_data->num_of_fingers);
- #endif
- f1a = NULL;
- if (!list_empty(&rmi->support_fn_list)) {
- list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
- if (fhandler->fn_number == SYNAPTICS_RMI4_F1A)
- f1a = fhandler->data;
- }
- }
- if (f1a) {
- for (ii = 0; ii < f1a->valid_button_count; ii++) {
- set_bit(f1a->button_map[ii],
- rmi4_data->input_dev->keybit);
- input_set_capability(rmi4_data->input_dev,
- EV_KEY, f1a->button_map[ii]);
- }
- }
- retval = input_register_device(rmi4_data->input_dev);
- if (retval) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to register input device\n",
- __func__);
- goto err_register_input;
- }
- return 0;
- err_register_input:
- input_free_device(rmi4_data->input_dev);
- err_query_device:
- synaptics_rmi4_release_support_fn(rmi4_data);
- err_input_device:
- return retval;
- }
- #ifdef CONFIG_SEC_TSP_FACTORY
- #include <asm/uaccess.h>
- #define LCD_LDI_FILE_PATH "/sys/class/lcd/panel/window_type"
- static int synaptics_rmi4_open_lcd_ldi(struct synaptics_rmi4_data *rmi4_data)
- {
- int iRet = 0;
- mm_segment_t old_fs;
- struct file *window_type;
- unsigned char lcdtype[4] = {0,};
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- window_type = filp_open(LCD_LDI_FILE_PATH, O_RDONLY, 0666);
- if (IS_ERR(window_type)) {
- iRet = PTR_ERR(window_type);
- if (iRet != -ENOENT)
- dev_err(&rmi4_data->i2c_client->dev, "%s: window_type file open fail\n", __func__);
- set_fs(old_fs);
- goto exit;
- }
- iRet = window_type->f_op->read(window_type, (u8 *)lcdtype, sizeof(u8) * 4, &window_type->f_pos);
- if (iRet != (sizeof(u8) * 4)) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: Can't read the lcd ldi data\n", __func__);
- iRet = -EIO;
- }
- /* The variable of lcdtype has ASCII values(40 81 45) at 0x08 OCTA,
- * so if someone need a TSP panel revision then to read third parameter.*/
- rmi4_data->panel_revision = lcdtype[3] & 0x0F;
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: update panel_revision 0x%02X\n", __func__, rmi4_data->panel_revision);
- filp_close(window_type, current->files);
- set_fs(old_fs);
- exit:
- return iRet;
- }
- #endif
- static int synaptics_rmi4_reinit_device(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char ii = 0;
- unsigned short intr_addr;
- struct synaptics_rmi4_fn *fhandler;
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- if (!list_empty(&rmi->support_fn_list)) {
- list_for_each_entry(fhandler, &rmi->support_fn_list, link) {
- if (fhandler->fn_number == SYNAPTICS_RMI4_F12) {
- retval = synaptics_rmi4_f12_set_enables(rmi4_data, 0);
- if (retval < 0)
- return retval;
- }
- #ifdef CONFIG_SEC_TSP_FACTORY
- /* Read firmware version from IC when every power up IC.
- * During Factory process touch panel can be changed manually.
- */
- if (fhandler->fn_number == SYNAPTICS_RMI4_F34) {
- synaptics_rmi4_open_lcd_ldi(rmi4_data);
- retval = synaptics_rmi4_f34_read_version(rmi4_data, fhandler);
- if (retval < 0)
- return retval;
- }
- #endif
- }
- }
- #ifdef CONFIG_GLOVE_TOUCH
- synaptics_rmi4_glove_mode_enables(rmi4_data);
- #endif
- #ifdef PROXIMITY
- if (!f51) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: f51 is no available.\n", __func__);
- } else {
- retval = synaptics_rmi4_f51_set_init(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: fail proximity set init\n",
- __func__);
- return retval;
- }
- }
- #endif
- for (ii = 0; ii < rmi4_data->num_of_intr_regs; ii++) {
- if (rmi4_data->intr_mask[ii] != 0x00) {
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: Interrupt enable mask register[%d] = 0x%02x\n",
- __func__, ii, rmi4_data->intr_mask[ii]);
- intr_addr = rmi4_data->f01_ctrl_base_addr + 1 + ii;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- intr_addr,
- &(rmi4_data->intr_mask[ii]),
- sizeof(rmi4_data->intr_mask[ii]));
- if (retval < 0)
- return retval;
- }
- }
- synaptics_rmi4_set_configured(rmi4_data);
- return 0;
- }
- static void synaptics_rmi4_release_all_finger(
- struct synaptics_rmi4_data *rmi4_data)
- {
- int ii;
- #ifdef TYPE_B_PROTOCOL
- for (ii = 0; ii < rmi4_data->num_of_fingers; ii++) {
- input_mt_slot(rmi4_data->input_dev, ii);
- input_mt_report_slot_state(rmi4_data->input_dev,
- MT_TOOL_FINGER, 0);
- }
- #else
- input_mt_sync(rmi4_data->input_dev);
- #endif
- input_report_key(rmi4_data->input_dev,
- BTN_TOUCH, 0);
- #ifdef CONFIG_GLOVE_TOUCH
- input_report_switch(rmi4_data->input_dev,
- SW_GLOVE, false);
- rmi4_data->touchkey_glove_mode_status = false;
- #endif
- input_sync(rmi4_data->input_dev);
- rmi4_data->fingers_on_2d = false;
- #ifdef PROXIMITY
- rmi4_data->f51_finger = false;
- #endif
- #ifdef TSP_BOOSTER
- synaptics_set_dvfs_lock(rmi4_data, -1);
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: dvfs_lock free.\n", __func__);
- #endif
- #ifdef USE_CUSTOM_REZERO
- cancel_delayed_work(&rmi4_data->rezero_work);
- #endif
- }
- static int synaptics_rmi4_reset_device(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char command = 0x01;
- mutex_lock(&(rmi4_data->rmi4_reset_mutex));
- disable_irq(rmi4_data->i2c_client->irq);
- synaptics_rmi4_release_all_finger(rmi4_data);
- if (!rmi4_data->stay_awake) {
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_cmd_base_addr,
- &command,
- sizeof(command));
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to issue reset command, error = %d\n",
- __func__, retval);
- goto out;
- }
- msleep(SYNAPTICS_HW_RESET_TIME);
- } else {
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(false);
- #endif
- synaptics_power_ctrl(rmi4_data,false);
- msleep(30);
- synaptics_power_ctrl(rmi4_data,true);
- rmi4_data->current_page = MASK_8BIT; // added Page masking routine for ghost touch
- msleep(SYNAPTICS_HW_RESET_TIME);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(true);
- #endif
- retval = synaptics_rmi4_f54_set_control(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to set f54 control\n",
- __func__);
- }
- synaptics_rmi4_release_support_fn(rmi4_data);
- retval = synaptics_rmi4_query_device(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to query device\n",
- __func__);
- }
- out:
- enable_irq(rmi4_data->i2c_client->irq);
- mutex_unlock(&(rmi4_data->rmi4_reset_mutex));
- return 0;
- }
- #ifdef TSP_PATTERN_TRACKING_METHOD
- static void synaptics_rmi4_reboot_work(struct work_struct *work)
- {
- int retval;
- struct synaptics_rmi4_data *rmi4_data =
- container_of(work, struct synaptics_rmi4_data,
- reboot_work.work);
- if(rmi4_data->ftouch_reboot == 1) return;
- rmi4_data->ftouch_reboot = 1;
- mutex_lock(&(rmi4_data->rmi4_reset_mutex));
- disable_irq(rmi4_data->i2c_client->irq);
- synaptics_rmi4_release_all_finger(rmi4_data);
- ghosttouchcount++;
- dev_err(&rmi4_data->i2c_client->dev,
- ": Tsp Reboot(%d) by pattern tracking\n",ghosttouchcount);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(false);
- #endif
- synaptics_power_ctrl(rmi4_data,false);
- msleep(50);
- synaptics_power_ctrl(rmi4_data,true);
- msleep(SYNAPTICS_HW_RESET_TIME);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(true);
- #endif
- retval = synaptics_rmi4_f54_set_control(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to set f54 control\n",
- __func__);
- synaptics_rmi4_release_support_fn(rmi4_data);
- retval = synaptics_rmi4_query_device(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to query device\n",
- __func__);
- }
- enable_irq(rmi4_data->i2c_client->irq);
- mutex_unlock(&(rmi4_data->rmi4_reset_mutex));
- rmi4_data->ftouch_reboot = 0;
- }
- #endif
- #ifdef SYNAPTICS_RMI_INFORM_CHARGER
- extern void synaptics_tsp_register_callback(struct synaptics_rmi_callbacks *cb);
- static void synaptics_charger_conn(struct synaptics_rmi4_data *rmi4_data,
- int ta_status)
- {
- int retval;
- unsigned char charger_connected;
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &charger_connected,
- sizeof(charger_connected));
- if (retval < 0) {
- dev_err(&(rmi4_data->input_dev->dev),
- "%s: Failed to set configured\n",
- __func__);
- return;
- }
- if (ta_status == 0x01 || ta_status == 0x03)
- charger_connected |= CHARGER_CONNECTED;
- else
- charger_connected &= CHARGER_DISCONNECTED;
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &charger_connected,
- sizeof(charger_connected));
- if (retval < 0) {
- dev_err(&(rmi4_data->input_dev->dev),
- "%s: Failed to set configured\n",
- __func__);
- }
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: device_control : %x, ta_status : %x\n",
- __func__, charger_connected, ta_status);
- }
- static void synaptics_ta_cb(struct synaptics_rmi_callbacks *cb, int ta_status)
- {
- struct synaptics_rmi4_data *rmi4_data =
- container_of(cb, struct synaptics_rmi4_data, callbacks);
- dev_info(&rmi4_data->i2c_client->dev,
- "%s: ta_status : %x\n", __func__, ta_status);
- rmi4_data->ta_status = ta_status;
- /* if do not completed driver loading, ta_cb will not run. */
- #ifdef TSP_INIT_COMPLETE
- if (!rmi4_data->init_done.done) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: until driver loading done.\n",
- __func__);
- return;
- }
- #endif
- if (rmi4_data->touch_stopped || rmi4_data->doing_reflash) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: device is in suspend state or reflash.\n",
- __func__);
- return;
- }
- synaptics_charger_conn(rmi4_data, ta_status);
- }
- #endif
- #ifdef PROXIMITY
- static void synaptics_rmi4_f51_finger_timer(unsigned long data)
- {
- struct synaptics_rmi4_data *rmi4_data =
- (struct synaptics_rmi4_data *)data;
- if (rmi4_data->f51_finger) {
- rmi4_data->f51_finger = false;
- mod_timer(&rmi4_data->f51_finger_timer,
- jiffies + msecs_to_jiffies(F51_FINGER_TIMEOUT));
- return;
- }
- if (!rmi4_data->fingers_on_2d) {
- #ifdef TYPE_B_PROTOCOL
- input_mt_slot(rmi4_data->input_dev, 0);
- input_mt_report_slot_state(rmi4_data->input_dev,
- MT_TOOL_FINGER, 0);
- #else
- input_mt_sync(rmi4_data->input_dev);
- #endif
- input_sync(rmi4_data->input_dev);
- }
- return;
- }
- #endif
- static void synaptics_rmi4_remove_exp_fn(struct synaptics_rmi4_data *rmi4_data)
- {
- struct synaptics_rmi4_exp_fn *exp_fhandler, *n;
- if (list_empty(&exp_fn_list)) {
- dev_err(&rmi4_data->i2c_client->dev, "%s: exp_fn_list empty\n",
- __func__);
- return;
- }
- list_for_each_entry_safe(exp_fhandler, n, &exp_fn_list, link) {
- if (exp_fhandler->initialized &&
- (exp_fhandler->func_remove != NULL)) {
- dev_dbg(&rmi4_data->i2c_client->dev, "%s: [%d]\n",
- __func__, exp_fhandler->fn_type);
- exp_fhandler->func_remove(rmi4_data);
- }
- list_del(&exp_fhandler->link);
- kfree(exp_fhandler);
- }
- }
- static int synaptics_rmi4_init_exp_fn(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- struct synaptics_rmi4_exp_fn *exp_fhandler;
- INIT_LIST_HEAD(&exp_fn_list);
- retval = rmidev_module_register();
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to register rmidev module\n",
- __func__);
- goto error_exit;
- }
- retval = rmi4_f54_module_register();
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to register f54 module\n",
- __func__);
- goto error_exit;
- }
- retval = rmi4_fw_update_module_register();
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to register fw update module\n",
- __func__);
- goto error_exit;
- }
- if (list_empty(&exp_fn_list))
- return -ENODEV;
- list_for_each_entry(exp_fhandler, &exp_fn_list, link) {
- if (exp_fhandler->func_init != NULL) {
- dev_dbg(&rmi4_data->i2c_client->dev, "%s: run [%d]'s init function\n",
- __func__, exp_fhandler->fn_type);
- retval = exp_fhandler->func_init(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to init exp fn\n",
- __func__);
- goto error_exit;
- } else {
- exp_fhandler->initialized = true;
- }
- }
- }
- return 0;
- error_exit:
- synaptics_rmi4_remove_exp_fn(rmi4_data);
- return retval;
- }
- /**
- * synaptics_rmi4_new_function()
- *
- * Called by other expansion Function modules in their module init and
- * module exit functions.
- *
- * This function is used by other expansion Function modules such as
- * rmi_dev to register themselves with the driver by providing their
- * initialization and removal callback function pointers so that they
- * can be inserted or removed dynamically at module init and exit times,
- * respectively.
- */
- int synaptics_rmi4_new_function(enum exp_fn fn_type,
- int (*func_init)(struct synaptics_rmi4_data *rmi4_data),
- void (*func_remove)(struct synaptics_rmi4_data *rmi4_data),
- void (*func_attn)(struct synaptics_rmi4_data *rmi4_data,
- unsigned char intr_mask))
- {
- struct synaptics_rmi4_exp_fn *exp_fhandler;
- exp_fhandler = kzalloc(sizeof(*exp_fhandler), GFP_KERNEL);
- if (!exp_fhandler) {
- pr_err("%s: Failed to alloc mem for expansion function\n",
- __func__);
- return -ENOMEM;
- }
- exp_fhandler->fn_type = fn_type;
- exp_fhandler->func_init = func_init;
- exp_fhandler->func_attn = func_attn;
- exp_fhandler->func_remove = func_remove;
- list_add_tail(&exp_fhandler->link, &exp_fn_list);
- return 0;
- }
- void synaptics_power_ctrl(struct synaptics_rmi4_data *rmi4_data, bool enable)
- {
- int ret = 0;
- #if defined(CONFIG_SEC_H_PROJECT) || defined(CONFIG_SEC_JS_PROJECT) || defined(CONFIG_MACH_JSGLTE_CHN_CMCC)
- static struct regulator *reg_l10;
- #endif
- pr_err("[synaptics] %s enable(%d)\n", __func__,enable);
- ret = gpio_direction_output(rmi4_data->pwrdata->vdd_io_1p8, enable);
- if (ret) {
- pr_err("[TKEY]%s: unable to set_direction for vdd_led [%d]\n",
- __func__, rmi4_data->pwrdata->vdd_io_1p8);
- }
- #if defined(CONFIG_SEC_H_PROJECT) || defined(CONFIG_SEC_JS_PROJECT) || defined(CONFIG_MACH_JSGLTE_CHN_CMCC)
- if (!reg_l10) {
- reg_l10 = regulator_get(NULL, "8941_l10");
- if (IS_ERR(reg_l10)) {
- pr_err("%s: could not get 8917_l10, rc = %ld\n",
- __func__, PTR_ERR(reg_l10));
- return;
- }
- ret = regulator_set_voltage(reg_l10, 1800000, 1800000);
- if (ret) {
- pr_err("%s: unable to set l10 voltage to 1.8V\n",
- __func__);
- return;
- }
- }
- if (enable) {
- if (regulator_is_enabled(reg_l10))
- pr_err( "%s: L10(1.8V) is enabled\n", __func__);
- else
- ret = regulator_enable(reg_l10);
- if (ret) {
- pr_err("%s: enable l10 failed, rc=%d\n",
- __func__, ret);
- return;
- }
- pr_info("%s: tsp 1.8V on is finished.\n", __func__);
- } else {
- if (regulator_is_enabled(reg_l10))
- ret = regulator_disable(reg_l10);
- else
- pr_err("%s: L10(1.8V) is disabled\n", __func__);
- if (ret) {
- pr_err("%s: disable l10 failed, rc=%d\n",
- __func__, ret);
- return;
- }
- pr_info("%s: tsp 1.8V off is finished.\n", __func__);
- }
- #endif
-
- #if !defined(CONFIG_SEC_H_PROJECT) && !defined(CONFIG_SEC_JS_PROJECT) && !defined(CONFIG_MACH_JSGLTE_CHN_CMCC)
- msleep(30);
- #endif
- return;
- }
- static int lcd_tsp_panel_version;
- static int atoi(char *str)
- {
- int ret = 0;
- int count = 0;
-
- if (str == NULL)
- return -EINVAL;
-
- while (str[count] != (int)NULL && str[count] >= '0'
- && str[count] <= 'z') {
- ret = ret * 0x10 + str[count] - '0';
- ++count;
- }
- return ret;
- }
-
- static int __init sec_tsp_mode(char *mode)
- {
- int ret, ret1;
-
- ret = atoi(mode);
- ret1 = ((ret >> 12) & 0X07);
-
- lcd_tsp_panel_version = ret;
-
- printk(KERN_ERR "%s: LCD_ID = 0x%s, val: 0X%x, ret1: 0x%x",
- __func__, mode, ret, ret1);
- // if (ret1 == 0x01 || ret1 == 0x04 || ret1 == 0x05 || ret == 0x0)
- // sec_tsp_synaptics_mode = 1;
- // else
- // sec_tsp_synaptics_mode = 0;
-
- return 1;
- }
- __setup("lcd_id=0x", sec_tsp_mode);
- #ifdef CONFIG_SEC_TSP_FACTORY
- unsigned int bootmode;
- static int __init sec_tsp_reboot_mode(char *mode)
- {
- int ret;
- ret = strncmp(mode, "1", 1);
- if (ret == 0)
- bootmode = 1;
- else
- bootmode = 0;
- printk(KERN_ERR "%s: %d, %s\n", __func__, ret, mode);
- return 1;
- }
- __setup("androidboot.check_recovery_condition=0x", sec_tsp_reboot_mode);
- #endif
- /**
- * synaptics_rmi4_probe()
- *
- * Called by the kernel when an association with an I2C device of the
- * same name is made (after doing i2c_add_driver).
- *
- * This funtion allocates and initializes the resources for the driver
- * as an input driver, turns on the power to the sensor, queries the
- * sensor for its supported Functions and characteristics, registers
- * the driver to the input subsystem, sets up the interrupt, handles
- * the registration of the early_suspend and late_resume functions,
- * and creates a work queue for detection of other expansion Function
- * modules.
- */
- static int __devinit synaptics_rmi4_probe(struct i2c_client *client,
- const struct i2c_device_id *dev_id)
- {
- int retval;
- unsigned char attr_count;
- int attr_count_num;
- struct synaptics_rmi4_data *rmi4_data;
- struct synaptics_rmi4_device_info *rmi;
- struct synaptics_rmi4_power_data *pdata;
- int error;
- #if !defined(CONFIG_SEC_MELIUSCA_PROJECT)
- int touch_fpcb_version;
- #endif
- struct synaptics_rmi4_platform_data *platform_data;
- platform_data = &rmi4_platformdata;
- printk(KERN_ERR "TSP %s",__func__);
- if (!i2c_check_functionality(client->adapter,
- I2C_FUNC_SMBUS_BYTE_DATA)) {
- dev_err(&client->dev,
- "%s: SMBus byte data not supported\n",
- __func__);
- return -EIO;
- }
- if (client->dev.of_node) {
- pdata = devm_kzalloc(&client->dev,
- sizeof(struct synaptics_rmi4_power_data),
- GFP_KERNEL);
- if (!pdata) {
- dev_err(&client->dev, "Failed to allocate memory\n");
- return -ENOMEM;
- }
- error = synaptics_parse_dt(&client->dev, pdata);
- if (error)
- return error;
- } else {
- pdata = client->dev.platform_data;
- printk(KERN_ERR "TSP failed to align dtsi %s",__func__);
- }
- synaptics_request_gpio(pdata);
- if (!platform_data) {
- dev_err(&client->dev,
- "%s: No platform data found\n",
- __func__);
- return -EINVAL;
- }
- rmi4_data = kzalloc(sizeof(*rmi4_data), GFP_KERNEL);
- if (!rmi4_data) {
- dev_err(&client->dev,
- "%s: Failed to alloc mem for rmi4_data\n",
- __func__);
- return -ENOMEM;
- }
- rmi = &(rmi4_data->rmi4_mod_info);
- rmi4_data->i2c_client = client;
- rmi4_data->current_page = MASK_8BIT;
- rmi4_data->board = platform_data; // Take care
- rmi4_data->pwrdata = pdata;
- rmi4_data->touch_stopped = false;
- rmi4_data->sensor_sleep = false;
- rmi4_data->irq_enabled = false;
- rmi4_data->tsp_probe = false;
- rmi4_data->rebootcount = 0;
- rmi4_data->panel_revision = rmi4_data->board->panel_revision;
- rmi4_data->i2c_read = synaptics_rmi4_i2c_read;
- rmi4_data->i2c_write = synaptics_rmi4_i2c_write;
- rmi4_data->irq_enable = synaptics_rmi4_irq_enable;
- rmi4_data->reset_device = synaptics_rmi4_reset_device;
- rmi4_data->stop_device = synaptics_rmi4_stop_device;
- rmi4_data->start_device = synaptics_rmi4_start_device;
- #ifdef CONFIG_SEC_TSP_FACTORY
- rmi4_data->bootmode = bootmode;
- dev_info(&client->dev,
- "%s: bootmode =%d\n",
- __func__,bootmode);
- #endif
- #if !defined(CONFIG_SEC_MELIUSCA_PROJECT)
- /* define panel version : M4 / M4+ */
- printk(KERN_ERR "%s system_rev = %d, octa version =0x%x",__func__,system_rev,lcd_tsp_panel_version);
- touch_fpcb_version = (lcd_tsp_panel_version & 0xF000) >> 12;
- printk(KERN_ERR "%s touch_fpcb_version =0x%x",__func__,touch_fpcb_version);
- /* Definition for firmware name according to panel ID
- *
- * ID, FPCB Name, User firmware, Factory firmware
- * ~ 4, FPCB 3.4, FW_IMAGE_NAME_B0_3_4, FAC_FWIMAGE_NAME_B0
- * ~ 4, FPCB 4.0, FW_IMAGE_NAME_B0_4_0, FAC_FWIMAGE_NAME_B0
- * 5, FPCB 4.3, FW_IMAGE_NAME_B0_4_3, FAC_FWIMAGE_NAME_B0
- * 6, FPCB 6.0, FW_IMAGE_NAME_B0_4_3, FAC_FWIMAGE_NAME_B0
- * 7, FPCB 7.x, FW_IMAGE_NAME_B0_4_3, FAC_FWIMAGE_NAME_B0
- * 8, FPCB 5.x, FW_IMAGE_NAME_B0_5_1, FAC_FWIMAGE_NAME_B0_5_1
- */
- #if defined(CONFIG_MACH_JACTIVESKT)
- rmi4_data->panel_revision = OCTA_PANEL_REVISION_40;
- rmi4_data->board->firmware_name = FW_IMAGE_NAME_B0_HSYNC04;
- rmi4_data->board->fac_firmware_name = FW_IMAGE_NAME_B0_HSYNC04_FAC;
- #else
- if(touch_fpcb_version == OCTA_PANEL_REVISION_51){
- rmi4_data->panel_revision = OCTA_PANEL_REVISION_51;
- rmi4_data->board->firmware_name = FW_IMAGE_NAME_B0_5_1;
- rmi4_data->board->fac_firmware_name = FAC_FWIMAGE_NAME_B0_5_1;
- }
- else{
- rmi4_data->panel_revision = OCTA_PANEL_REVISION_43;
- rmi4_data->board->firmware_name = FW_IMAGE_NAME_B0_4_3;
- rmi4_data->board->fac_firmware_name = FAC_FWIMAGE_NAME_B0;
- }
- #endif
- #else
- rmi4_data->panel_revision = 0x00;
- rmi4_data->board->firmware_name = FW_IMAGE_NAME_B0_NEP_14;
- rmi4_data->board->fac_firmware_name = FW_IMAGE_NAME_B0_NEP_1F;
- #endif
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(false);
- #endif
- touch_sleep_time = SYNAPTICS_HW_RESET_TIME;
- synaptics_power_ctrl(rmi4_data,true);
- msleep(touch_sleep_time);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(true);
- #endif
- mutex_init(&(rmi4_data->rmi4_io_ctrl_mutex));
- mutex_init(&(rmi4_data->rmi4_reset_mutex));
- mutex_init(&(rmi4_data->rmi4_reflash_mutex));
- mutex_init(&(rmi4_data->rmi4_device_mutex));
- #ifdef TSP_INIT_COMPLETE
- init_completion(&rmi4_data->init_done);
- #endif
- #ifdef USE_OPEN_DWORK
- INIT_DELAYED_WORK(&rmi4_data->open_work, synaptics_rmi4_open_work);
- #endif
- #ifdef USE_CUSTOM_REZERO
- INIT_DELAYED_WORK(&rmi4_data->rezero_work, synaptics_rmi4_rezero_work);
- #endif
- #ifdef TSP_PATTERN_TRACKING_METHOD
- INIT_DELAYED_WORK(&rmi4_data->reboot_work, synaptics_rmi4_reboot_work);
- #endif
- i2c_set_clientdata(client, rmi4_data);
- err_tsp_reboot:
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(false);
- #endif
- synaptics_power_ctrl(rmi4_data,true);
- msleep(SYNAPTICS_POWER_MARGIN_TIME);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(true);
- #endif
- #ifdef TSP_BOOSTER
- synaptics_init_dvfs(rmi4_data);
- #endif
- retval = synaptics_rmi4_set_input_device(rmi4_data);
- if (retval < 0) {
- dev_err(&client->dev,
- "%s: Failed to set up input device\n",
- __func__);
- if((retval == TSP_NEEDTO_REBOOT)&&(rmi4_data->rebootcount< MAX_TSP_REBOOT)){
- synaptics_power_ctrl(rmi4_data,false);
- msleep(SYNAPTICS_POWER_MARGIN_TIME);
- msleep(SYNAPTICS_POWER_MARGIN_TIME);
- rmi4_data->rebootcount++;
- dev_err(&client->dev,
- "%s: reboot sequence by i2c fail\n",
- __func__);
- goto err_tsp_reboot;
- }
- else goto err_set_input_device;
- }
- retval = synaptics_rmi4_init_exp_fn(rmi4_data);
- if (retval < 0) {
- dev_err(&client->dev,
- "%s: Failed to register rmidev module\n",
- __func__);
- goto err_init_exp_fn;
- }
- /*
- if (platform_data->gpio_config) {
- retval = platform_data->gpio_config(platform_data->gpio, true);
- if (retval < 0) {
- dev_err(&client->dev,
- "%s: Failed to configure GPIO\n",
- __func__);
- goto err_gpio;
- }
- }
- */
- client->irq = gpio_to_irq(pdata->tsp_int);
- printk(KERN_ERR "%s: tsp : gpio_to_irq : %d\n", __func__, client->irq);
- rmi4_data->irq = client->irq;
- printk(KERN_ERR "%s: ln:%d\n", __func__, __LINE__);
- retval = synaptics_rmi4_irq_enable(rmi4_data, true);
- if (retval < 0) {
- dev_err(&client->dev,
- "%s: Failed to enable attention interrupt\n",
- __func__);
- goto err_enable_irq;
- }
- for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
- retval = sysfs_create_file(&rmi4_data->input_dev->dev.kobj,
- &attrs[attr_count].attr);
- if (retval < 0) {
- dev_err(&client->dev,
- "%s: Failed to create sysfs attributes\n",
- __func__);
- goto err_sysfs;
- }
- }
- retval = synaptics_rmi4_fw_update_on_probe(rmi4_data);
- if (retval < 0) {
- dev_err(&client->dev, "%s: Failed to firmware update\n",
- __func__);
- }
- #ifdef CONFIG_HAS_EARLYSUSPEND
- rmi4_data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN -2;
- rmi4_data->early_suspend.suspend = synaptics_rmi4_early_suspend;
- rmi4_data->early_suspend.resume = synaptics_rmi4_late_resume;
- register_early_suspend(&rmi4_data->early_suspend);
- #endif
- #ifdef SYNAPTICS_RMI_INFORM_CHARGER
- rmi4_data->register_cb = synaptics_tsp_register_callback;
- rmi4_data->callbacks.inform_charger = synaptics_ta_cb;
- if (rmi4_data->register_cb){
- dev_err(&client->dev, "[TSP] Register TA Callback\n");
- rmi4_data->register_cb(&rmi4_data->callbacks);
- }
- #endif
- /* for blocking to be excuted open function until probing */
- rmi4_data->tsp_probe = true;
- #ifdef TSP_INIT_COMPLETE
- complete_all(&rmi4_data->init_done);
- #endif
- #if !defined(CONFIG_SEC_MELIUSCA_PROJECT)
- #ifdef TSP_TURNOFF_AFTER_PROBE
- synaptics_rmi4_stop_device(rmi4_data);
- #endif
- #endif
- return retval;
- err_sysfs:
- attr_count_num = (int)attr_count;
- for (attr_count_num--; attr_count_num >= 0; attr_count_num--) {
- sysfs_remove_file(&rmi4_data->input_dev->dev.kobj,
- &attrs[attr_count].attr);
- }
- synaptics_rmi4_irq_enable(rmi4_data, false);
- err_enable_irq:
- synaptics_rmi4_remove_exp_fn(rmi4_data);
- err_init_exp_fn:
- synaptics_rmi4_release_support_fn(rmi4_data);
- input_unregister_device(rmi4_data->input_dev);
- rmi4_data->input_dev = NULL;
- err_set_input_device:
- synaptics_power_ctrl(rmi4_data,false);
- #ifdef TSP_INIT_COMPLETE
- complete_all(&rmi4_data->init_done);
- #endif
- kfree(rmi4_data);
- return retval;
- }
- /**
- * synaptics_rmi4_remove()
- *
- * Called by the kernel when the association with an I2C device of the
- * same name is broken (when the driver is unloaded).
- *
- * This funtion terminates the work queue, stops sensor data acquisition,
- * frees the interrupt, unregisters the driver from the input subsystem,
- * turns off the power to the sensor, and frees other allocated resources.
- */
- static int __devexit synaptics_rmi4_remove(struct i2c_client *client)
- {
- unsigned char attr_count;
- struct synaptics_rmi4_data *rmi4_data = i2c_get_clientdata(client);
- struct synaptics_rmi4_device_info *rmi;
- rmi = &(rmi4_data->rmi4_mod_info);
- #ifdef CONFIG_HAS_EARLYSUSPEND
- unregister_early_suspend(&rmi4_data->early_suspend);
- #endif
- synaptics_rmi4_irq_enable(rmi4_data, false);
- for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
- sysfs_remove_file(&rmi4_data->input_dev->dev.kobj,
- &attrs[attr_count].attr);
- }
- input_unregister_device(rmi4_data->input_dev);
- synaptics_rmi4_remove_exp_fn(rmi4_data);
- synaptics_power_ctrl(rmi4_data,false);
- rmi4_data->touch_stopped = true;
- synaptics_rmi4_release_support_fn(rmi4_data);
- input_free_device(rmi4_data->input_dev);
- kfree(rmi4_data);
- return 0;
- }
- #ifdef USE_SENSOR_SLEEP
- /**
- * synaptics_rmi4_sensor_sleep()
- *
- * Called by synaptics_rmi4_early_suspend() and synaptics_rmi4_suspend().
- *
- * This function stops finger data acquisition and puts the sensor to sleep.
- */
- static void synaptics_rmi4_sensor_sleep(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char device_ctrl;
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to enter sleep mode\n",
- __func__);
- rmi4_data->sensor_sleep = false;
- return;
- }
- device_ctrl = (device_ctrl & ~MASK_3BIT);
- device_ctrl = (device_ctrl | NO_SLEEP_OFF | SENSOR_SLEEP);
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to enter sleep mode\n",
- __func__);
- rmi4_data->sensor_sleep = false;
- return;
- } else {
- rmi4_data->sensor_sleep = true;
- }
- return;
- }
- /**
- * synaptics_rmi4_sensor_wake()
- *
- * Called by synaptics_rmi4_resume() and synaptics_rmi4_late_resume().
- *
- * This function wakes the sensor from sleep.
- */
- static void synaptics_rmi4_sensor_wake(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval;
- unsigned char device_ctrl;
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- retval = synaptics_rmi4_i2c_read(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to wake from sleep mode\n",
- __func__);
- rmi4_data->sensor_sleep = true;
- return;
- }
- device_ctrl = (device_ctrl & ~MASK_3BIT);
- device_ctrl = (device_ctrl | NO_SLEEP_OFF | NORMAL_OPERATION);
- retval = synaptics_rmi4_i2c_write(rmi4_data,
- rmi4_data->f01_ctrl_base_addr,
- &device_ctrl,
- sizeof(device_ctrl));
- if (retval < 0) {
- dev_err(&(rmi4_data->i2c_client->dev),
- "%s: Failed to wake from sleep mode\n",
- __func__);
- rmi4_data->sensor_sleep = true;
- return;
- } else {
- rmi4_data->sensor_sleep = false;
- }
- return;
- }
- #endif
- static int synaptics_rmi4_stop_device(struct synaptics_rmi4_data *rmi4_data)
- {
- mutex_lock(&rmi4_data->rmi4_device_mutex);
- if (rmi4_data->touch_stopped) {
- dev_err(&rmi4_data->i2c_client->dev, "%s already power off\n",
- __func__);
- goto out;
- }
- disable_irq(rmi4_data->i2c_client->irq);
- synaptics_rmi4_release_all_finger(rmi4_data);
- rmi4_data->touch_stopped = true;
- synaptics_power_ctrl(rmi4_data,false);
- mdss_dsi_panel_touchsensing(false);
- dev_dbg(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- out:
- mutex_unlock(&rmi4_data->rmi4_device_mutex);
- return 0;
- }
- static int synaptics_rmi4_start_device(struct synaptics_rmi4_data *rmi4_data)
- {
- int retval = 0;
- mutex_lock(&rmi4_data->rmi4_device_mutex);
- rmi4_data->current_page = MASK_8BIT; // added Page masking routine for ghost touch
- if (!rmi4_data->touch_stopped) {
- dev_err(&rmi4_data->i2c_client->dev, "%s already power on\n",
- __func__);
- goto out;
- }
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(false);
- #endif
- synaptics_power_ctrl(rmi4_data,true);
- rmi4_data->touch_stopped = false;
- mdss_dsi_panel_touchsensing(true);
- msleep(SYNAPTICS_HW_RESET_TIME);
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_PREVENT_HSYNC_LEAKAGE)
- rmi4_data->board->hsync_onoff(true);
- #endif
- retval = synaptics_rmi4_reinit_device(rmi4_data);
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to reinit device\n",
- __func__);
- }
- enable_irq(rmi4_data->i2c_client->irq);
- dev_dbg(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- out:
- mutex_unlock(&rmi4_data->rmi4_device_mutex);
- return retval;
- }
- #ifdef USE_OPEN_CLOSE
- #ifdef USE_OPEN_DWORK
- static void synaptics_rmi4_open_work(struct work_struct *work)
- {
- int retval;
- struct synaptics_rmi4_data *rmi4_data =
- container_of(work, struct synaptics_rmi4_data,
- open_work.work);
- retval = synaptics_rmi4_start_device(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to start device\n", __func__);
- }
- #endif
- static int synaptics_rmi4_input_open(struct input_dev *dev)
- {
- struct synaptics_rmi4_data *rmi4_data = input_get_drvdata(dev);
- int retval;
- #ifdef TSP_INIT_COMPLETE
- #if !defined(CONFIG_SEC_MELIUSCA_PROJECT)
- retval = wait_for_completion_interruptible_timeout(&rmi4_data->init_done,
- msecs_to_jiffies(60 * MSEC_PER_SEC));
- #else
- retval = wait_for_completion_interruptible_timeout(&rmi4_data->init_done,
- msecs_to_jiffies(10 * MSEC_PER_SEC));
- #endif
- if (retval < 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "error while waiting for device to init (%d)\n", retval);
- retval = -ENXIO;
- goto err_open;
- }
- if (retval == 0) {
- dev_err(&rmi4_data->i2c_client->dev,
- "timedout while waiting for device to init\n");
- retval = -ENXIO;
- goto err_open;
- }
- #endif
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- #ifdef USE_OPEN_DWORK
- schedule_delayed_work(&rmi4_data->open_work,
- msecs_to_jiffies(TOUCH_OPEN_DWORK_TIME));
- #else
- retval = synaptics_rmi4_start_device(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to start device\n", __func__);
- #endif
- return 0;
- #ifdef TSP_INIT_COMPLETE
- err_open:
- return retval;
- #endif
- }
- static void synaptics_rmi4_input_close(struct input_dev *dev)
- {
- struct synaptics_rmi4_data *rmi4_data = input_get_drvdata(dev);
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- #ifdef TSP_PATTERN_TRACKING_METHOD
- if(rmi4_data->ftouch_reboot == 1){
- dev_info(&rmi4_data->i2c_client->dev, "%s skip close \n", __func__);
- return;
- }
- #endif
- #ifdef USE_OPEN_DWORK
- cancel_delayed_work(&rmi4_data->open_work);
- #endif
- #ifdef TSP_PATTERN_TRACKING_METHOD
- cancel_delayed_work(&rmi4_data->reboot_work);
- #endif
- synaptics_rmi4_stop_device(rmi4_data);
- }
- #endif
- #ifdef CONFIG_PM
- #ifdef CONFIG_HAS_EARLYSUSPEND
- #define synaptics_rmi4_suspend NULL
- #define synaptics_rmi4_resume NULL
-
- /**
- * synaptics_rmi4_early_suspend()
- *
- * Called by the kernel during the early suspend phase when the system
- * enters suspend.
- *
- * This function calls synaptics_rmi4_sensor_sleep() to stop finger
- * data acquisition and put the sensor to sleep.
- */
- static void synaptics_rmi4_early_suspend(struct early_suspend *h)
- {
- struct synaptics_rmi4_data *rmi4_data =
- container_of(h, struct synaptics_rmi4_data,
- early_suspend);
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- if (rmi4_data->stay_awake) {
- rmi4_data->staying_awake = true;
- dev_info(&rmi4_data->i2c_client->dev, "%s : return due to staying_awake\n",
- __func__);
- return;
- } else {
- rmi4_data->staying_awake = false;
- }
- synaptics_rmi4_stop_device(rmi4_data);
- return;
- }
- /**
- * synaptics_rmi4_late_resume()
- *
- * Called by the kernel during the late resume phase when the system
- * wakes up from suspend.
- *
- * This function goes through the sensor wake process if the system wakes
- * up from early suspend (without going into suspend).
- */
- static void synaptics_rmi4_late_resume(struct early_suspend *h)
- {
- int retval = 0;
- struct synaptics_rmi4_data *rmi4_data =
- container_of(h, struct synaptics_rmi4_data,
- early_suspend);
- dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- if (rmi4_data->staying_awake) {
- dev_info(&rmi4_data->i2c_client->dev, "%s : return due to staying_awake\n",
- __func__);
- return;
- }
- retval = synaptics_rmi4_start_device(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to start device\n", __func__);
- return;
- }
- #else
- /**
- * synaptics_rmi4_suspend()
- *
- * Called by the kernel during the suspend phase when the system
- * enters suspend.
- *
- * This function stops finger data acquisition and puts the sensor to
- * sleep (if not already done so during the early suspend phase),
- * disables the interrupt, and turns off the power to the sensor.
- */
- static int synaptics_rmi4_suspend(struct device *dev)
- {
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- dev_dbg(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- if (rmi4_data->staying_awake) {
- dev_info(&rmi4_data->i2c_client->dev, "%s : return due to staying_awake\n",
- __func__);
- return 0;
- }
- mutex_lock(&rmi4_data->input_dev->mutex);
- if (rmi4_data->input_dev->users)
- synaptics_rmi4_stop_device(rmi4_data);
- mutex_unlock(&rmi4_data->input_dev->mutex);
- return 0;
- }
- /**
- * synaptics_rmi4_resume()
- *
- * Called by the kernel during the resume phase when the system
- * wakes up from suspend.
- *
- * This function turns on the power to the sensor, wakes the sensor
- * from sleep, enables the interrupt, and starts finger data
- * acquisition.
- */
- static int synaptics_rmi4_resume(struct device *dev)
- {
- int retval;
- struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
- dev_dbg(&rmi4_data->i2c_client->dev, "%s\n", __func__);
- mutex_lock(&rmi4_data->input_dev->mutex);
- if (rmi4_data->input_dev->users) {
- retval = synaptics_rmi4_start_device(rmi4_data);
- if (retval < 0)
- dev_err(&rmi4_data->i2c_client->dev,
- "%s: Failed to start device\n", __func__);
- }
- mutex_unlock(&rmi4_data->input_dev->mutex);
- return 0;
- }
- #endif
- static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = {
- .suspend = synaptics_rmi4_suspend,
- .resume = synaptics_rmi4_resume,
- };
- #endif
- static const struct i2c_device_id synaptics_rmi4_id_table[] = {
- {DRIVER_NAME, 0},
- {},
- };
- MODULE_DEVICE_TABLE(i2c, synaptics_rmi4_id_table);
- #ifdef CONFIG_OF
- static struct of_device_id synaptics_match_table[] = {
- { .compatible = "synaptics,rmi4-ts",},
- { },
- };
- #else
- #define synaptics_match_table NULL
- #endif
- static struct i2c_driver synaptics_rmi4_driver = {
- .driver = {
- .name = DRIVER_NAME,
- .owner = THIS_MODULE,
- .of_match_table = synaptics_match_table,
- #ifdef CONFIG_PM
- .pm = &synaptics_rmi4_dev_pm_ops,
- #endif
- },
- .probe = synaptics_rmi4_probe,
- .remove = __devexit_p(synaptics_rmi4_remove),
- .id_table = synaptics_rmi4_id_table,
- };
- /**
- * synaptics_rmi4_init()
- *
- * Called by the kernel during do_initcalls (if built-in)
- * or when the driver is loaded (if a module).
- *
- * This function registers the driver to the I2C subsystem.
- *
- */
- static int __init synaptics_rmi4_init(void)
- {
- printk(KERN_ERR "TSP %s: ln:%d\n", __func__, __LINE__);
- return i2c_add_driver(&synaptics_rmi4_driver);
- }
- /**
- * synaptics_rmi4_exit()
- *
- * Called by the kernel when the driver is unloaded.
- *
- * This funtion unregisters the driver from the I2C subsystem.
- *
- */
- static void __exit synaptics_rmi4_exit(void)
- {
- i2c_del_driver(&synaptics_rmi4_driver);
- }
- module_init(synaptics_rmi4_init);
- module_exit(synaptics_rmi4_exit);
- MODULE_AUTHOR("Synaptics, Inc.");
- MODULE_DESCRIPTION("Synaptics RMI4 I2C Touch Driver");
- MODULE_LICENSE("GPL v2");
- MODULE_VERSION(SYNAPTICS_RMI4_DRIVER_VERSION);
|