rmi_f54.c 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790
  1. /* Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver.
  2. * Copyright (c) 2007-2012, Synaptics Incorporated
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <asm/unaligned.h>
  17. //#include <mach/cpufreq.h>
  18. #include <linux/slab.h>
  19. #include <linux/i2c.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/delay.h>
  22. #include <linux/input.h>
  23. #include <linux/ctype.h>
  24. #include <linux/hrtimer.h>
  25. #include <linux/firmware.h>
  26. #include "synaptics_i2c_rmi.h"
  27. #define FACTORY_MODE
  28. #define CMD_REPORT_TYPE_DELTA 2
  29. #define CMD_REPORT_TYPE_RAWCAP 20
  30. #define CMD_GET_REPORT 1
  31. #define TSP_RAWCAP_MAX 6000
  32. #define TSP_RAWCAP_MIN 300
  33. #define TSP_DELTA_MAX 10
  34. #define TSP_DELTA_MIN -10
  35. #define WATCHDOG_HRTIMER
  36. #define WATCHDOG_TIMEOUT_S 2
  37. #define FORCE_TIMEOUT_100MS 10
  38. #define STATUS_WORK_INTERVAL 20 /* ms */
  39. /*
  40. #define RAW_HEX
  41. #define HUMAN_READABLE
  42. */
  43. #define STATUS_IDLE 0
  44. #define STATUS_BUSY 1
  45. #define STATUS_ERROR 2
  46. #define DATA_REPORT_INDEX_OFFSET 1
  47. #define DATA_REPORT_DATA_OFFSET 3
  48. #define COMMAND_GET_REPORT 1
  49. #define COMMAND_FORCE_CAL 2
  50. #define COMMAND_FORCE_UPDATE 4
  51. #define HIGH_RESISTANCE_DATA_SIZE 6
  52. #define FULL_RAW_CAP_MIN_MAX_DATA_SIZE 4
  53. #define TREX_DATA_SIZE 7
  54. #define NO_AUTO_CAL_MASK 0x01
  55. #define concat(a, b) a##b
  56. #define tostring(x) (#x)
  57. #define GROUP(_attrs) {\
  58. .attrs = _attrs,\
  59. }
  60. #define attrify(propname) (&dev_attr_##propname.attr)
  61. #define show_prototype(propname)\
  62. static ssize_t concat(synaptics_rmi4_f54, _##propname##_show)(\
  63. struct device *dev,\
  64. struct device_attribute *attr,\
  65. char *buf);\
  66. \
  67. struct device_attribute dev_attr_##propname =\
  68. __ATTR(propname, S_IRUGO,\
  69. concat(synaptics_rmi4_f54, _##propname##_show),\
  70. synaptics_rmi4_store_error);
  71. #define store_prototype(propname)\
  72. static ssize_t concat(synaptics_rmi4_f54, _##propname##_store)(\
  73. struct device *dev,\
  74. struct device_attribute *attr,\
  75. const char *buf, size_t count);\
  76. \
  77. struct device_attribute dev_attr_##propname =\
  78. __ATTR(propname, S_IWUSR | S_IWGRP,\
  79. synaptics_rmi4_show_error,\
  80. concat(synaptics_rmi4_f54, _##propname##_store));
  81. #define show_store_prototype(propname)\
  82. static ssize_t concat(synaptics_rmi4_f54, _##propname##_show)(\
  83. struct device *dev,\
  84. struct device_attribute *attr,\
  85. char *buf);\
  86. \
  87. static ssize_t concat(synaptics_rmi4_f54, _##propname##_store)(\
  88. struct device *dev,\
  89. struct device_attribute *attr,\
  90. const char *buf, size_t count);\
  91. \
  92. struct device_attribute dev_attr_##propname =\
  93. __ATTR(propname, (S_IRUGO | S_IWUSR | S_IWGRP),\
  94. concat(synaptics_rmi4_f54, _##propname##_show),\
  95. concat(synaptics_rmi4_f54, _##propname##_store));
  96. #define simple_show_func(rtype, propname, fmt)\
  97. static ssize_t concat(synaptics_rmi4_f54, _##propname##_show)(\
  98. struct device *dev,\
  99. struct device_attribute *attr,\
  100. char *buf)\
  101. {\
  102. return snprintf(buf, PAGE_SIZE, fmt, f54->rtype.propname);\
  103. } \
  104. #define simple_show_func_unsigned(rtype, propname)\
  105. simple_show_func(rtype, propname, "%u\n")
  106. #define show_func(rtype, rgrp, propname, fmt)\
  107. static ssize_t concat(synaptics_rmi4_f54, _##propname##_show)(\
  108. struct device *dev,\
  109. struct device_attribute *attr,\
  110. char *buf)\
  111. {\
  112. int retval;\
  113. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;\
  114. \
  115. mutex_lock(&f54->rtype##_mutex);\
  116. \
  117. retval = f54->fn_ptr->read(rmi4_data,\
  118. f54->rtype.rgrp->address,\
  119. f54->rtype.rgrp->data,\
  120. sizeof(f54->rtype.rgrp->data));\
  121. mutex_unlock(&f54->rtype##_mutex);\
  122. if (retval < 0) {\
  123. dev_err(&rmi4_data->i2c_client->dev,\
  124. "%s: Failed to read " #rtype\
  125. " " #rgrp "\n",\
  126. __func__);\
  127. return retval;\
  128. } \
  129. \
  130. return snprintf(buf, PAGE_SIZE, fmt,\
  131. f54->rtype.rgrp->propname);\
  132. } \
  133. #define show_store_func(rtype, rgrp, propname, fmt)\
  134. show_func(rtype, rgrp, propname, fmt)\
  135. \
  136. static ssize_t concat(synaptics_rmi4_f54, _##propname##_store)(\
  137. struct device *dev,\
  138. struct device_attribute *attr,\
  139. const char *buf, size_t count)\
  140. {\
  141. int retval;\
  142. unsigned long setting;\
  143. unsigned long o_setting;\
  144. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;\
  145. \
  146. retval = kstrtoul(buf, 10, &setting);\
  147. if (retval)\
  148. return retval;\
  149. \
  150. mutex_lock(&f54->rtype##_mutex);\
  151. retval = f54->fn_ptr->read(rmi4_data,\
  152. f54->rtype.rgrp->address,\
  153. f54->rtype.rgrp->data,\
  154. sizeof(f54->rtype.rgrp->data));\
  155. if (retval < 0) {\
  156. mutex_unlock(&f54->rtype##_mutex);\
  157. dev_err(&rmi4_data->i2c_client->dev,\
  158. "%s: Failed to read " #rtype\
  159. " " #rgrp "\n",\
  160. __func__);\
  161. return retval;\
  162. } \
  163. \
  164. if (f54->rtype.rgrp->propname == setting) {\
  165. mutex_unlock(&f54->rtype##_mutex);\
  166. return count;\
  167. } \
  168. \
  169. o_setting = f54->rtype.rgrp->propname;\
  170. f54->rtype.rgrp->propname = setting;\
  171. \
  172. retval = f54->fn_ptr->write(rmi4_data,\
  173. f54->rtype.rgrp->address,\
  174. f54->rtype.rgrp->data,\
  175. sizeof(f54->rtype.rgrp->data));\
  176. if (retval < 0) {\
  177. dev_err(&rmi4_data->i2c_client->dev,\
  178. "%s: Failed to write " #rtype\
  179. " " #rgrp "\n",\
  180. __func__);\
  181. f54->rtype.rgrp->propname = o_setting;\
  182. mutex_unlock(&f54->rtype##_mutex);\
  183. return retval;\
  184. } \
  185. \
  186. mutex_unlock(&f54->rtype##_mutex);\
  187. return count;\
  188. } \
  189. #define show_store_func_unsigned(rtype, rgrp, propname)\
  190. show_store_func(rtype, rgrp, propname, "%u\n")
  191. #define show_replicated_func(rtype, rgrp, propname, fmt)\
  192. static ssize_t concat(synaptics_rmi4_f54, _##propname##_show)(\
  193. struct device *dev,\
  194. struct device_attribute *attr,\
  195. char *buf)\
  196. {\
  197. int retval;\
  198. int size = 0;\
  199. unsigned char ii;\
  200. unsigned char length;\
  201. unsigned char *temp;\
  202. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;\
  203. \
  204. mutex_lock(&f54->rtype##_mutex);\
  205. \
  206. length = f54->rtype.rgrp->length;\
  207. \
  208. retval = f54->fn_ptr->read(rmi4_data,\
  209. f54->rtype.rgrp->address,\
  210. (unsigned char *)f54->rtype.rgrp->data,\
  211. length);\
  212. mutex_unlock(&f54->rtype##_mutex);\
  213. if (retval < 0) {\
  214. dev_dbg(&rmi4_data->i2c_client->dev,\
  215. "%s: Failed to read " #rtype\
  216. " " #rgrp "\n",\
  217. __func__);\
  218. } \
  219. \
  220. temp = buf;\
  221. \
  222. for (ii = 0; ii < length; ii++) {\
  223. retval = snprintf(temp, PAGE_SIZE - size, fmt " ",\
  224. f54->rtype.rgrp->data[ii].propname);\
  225. if (retval < 0) {\
  226. dev_err(&rmi4_data->i2c_client->dev,\
  227. "%s: Faild to write output\n",\
  228. __func__);\
  229. return retval;\
  230. } \
  231. size += retval;\
  232. temp += retval;\
  233. } \
  234. \
  235. retval = snprintf(temp, PAGE_SIZE - size, "\n");\
  236. if (retval < 0) {\
  237. dev_err(&rmi4_data->i2c_client->dev,\
  238. "%s: Faild to write null terminator\n",\
  239. __func__);\
  240. return retval;\
  241. } \
  242. \
  243. return size + retval;\
  244. } \
  245. #define show_replicated_func_unsigned(rtype, rgrp, propname)\
  246. show_replicated_func(rtype, rgrp, propname, "%u")
  247. #define show_store_replicated_func(rtype, rgrp, propname, fmt)\
  248. show_replicated_func(rtype, rgrp, propname, fmt)\
  249. \
  250. static ssize_t concat(synaptics_rmi4_f54, _##propname##_store)(\
  251. struct device *dev,\
  252. struct device_attribute *attr,\
  253. const char *buf, size_t count)\
  254. {\
  255. int retval;\
  256. unsigned int setting;\
  257. unsigned char ii;\
  258. unsigned char length;\
  259. const unsigned char *temp;\
  260. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;\
  261. \
  262. mutex_lock(&f54->rtype##_mutex);\
  263. \
  264. length = f54->rtype.rgrp->length;\
  265. \
  266. retval = f54->fn_ptr->read(rmi4_data,\
  267. f54->rtype.rgrp->address,\
  268. (unsigned char *)f54->rtype.rgrp->data,\
  269. length);\
  270. if (retval < 0) {\
  271. dev_dbg(&rmi4_data->i2c_client->dev,\
  272. "%s: Failed to read " #rtype\
  273. " " #rgrp "\n",\
  274. __func__);\
  275. } \
  276. \
  277. temp = buf;\
  278. \
  279. for (ii = 0; ii < length; ii++) {\
  280. if (sscanf(temp, fmt, &setting) == 1) {\
  281. f54->rtype.rgrp->data[ii].propname = setting;\
  282. } else {\
  283. retval = f54->fn_ptr->read(rmi4_data,\
  284. f54->rtype.rgrp->address,\
  285. (unsigned char *)f54->rtype.rgrp->data,\
  286. length);\
  287. mutex_unlock(&f54->rtype##_mutex);\
  288. return -EINVAL;\
  289. } \
  290. \
  291. while (*temp != 0) {\
  292. temp++;\
  293. if (isspace(*(temp - 1)) && !isspace(*temp))\
  294. break;\
  295. } \
  296. } \
  297. \
  298. retval = f54->fn_ptr->write(rmi4_data,\
  299. f54->rtype.rgrp->address,\
  300. (unsigned char *)f54->rtype.rgrp->data,\
  301. length);\
  302. mutex_unlock(&f54->rtype##_mutex);\
  303. if (retval < 0) {\
  304. dev_err(&rmi4_data->i2c_client->dev,\
  305. "%s: Failed to write " #rtype\
  306. " " #rgrp "\n",\
  307. __func__);\
  308. return retval;\
  309. } \
  310. \
  311. return count;\
  312. } \
  313. #define show_store_replicated_func_unsigned(rtype, rgrp, propname)\
  314. show_store_replicated_func(rtype, rgrp, propname, "%u")
  315. enum f54_report_types {
  316. F54_8BIT_IMAGE = 1,
  317. F54_16BIT_IMAGE = 2,
  318. F54_RAW_16BIT_IMAGE = 3,
  319. F54_HIGH_RESISTANCE = 4,
  320. F54_TX_TO_TX_SHORT = 5,
  321. F54_RX_TO_RX1 = 7,
  322. F54_TRUE_BASELINE = 9,
  323. F54_FULL_RAW_CAP_MIN_MAX = 13,
  324. F54_RX_OPENS1 = 14,
  325. F54_TX_OPEN = 15,
  326. F54_TX_TO_GROUND = 16,
  327. F54_RX_TO_RX2 = 17,
  328. F54_RX_OPENS2 = 18,
  329. F54_FULL_RAW_CAP = 19,
  330. F54_FULL_RAW_CAP_RX_COUPLING_COMP = 20,
  331. F54_SENSOR_SPEED = 22,
  332. F54_ADC_RANGE = 23,
  333. F54_TREX_OPENS = 24,
  334. F54_TREX_TO_GND = 25,
  335. F54_TREX_SHORTS = 26,
  336. F54_ABS_RAW_CAP = 38,
  337. F54_ABS_DELTA_CAP = 40,
  338. INVALID_REPORT_TYPE = -1,
  339. };
  340. struct f54_query {
  341. union {
  342. struct {
  343. /* query 0 */
  344. unsigned char num_of_rx_electrodes;
  345. /* query 1 */
  346. unsigned char num_of_tx_electrodes;
  347. /* query 2 */
  348. unsigned char f54_query2_b0__1:2;
  349. unsigned char has_baseline:1;
  350. unsigned char has_image8:1;
  351. unsigned char f54_query2_b4__5:2;
  352. unsigned char has_image16:1;
  353. unsigned char f54_query2_b7:1;
  354. /* queries 3.0 and 3.1 */
  355. unsigned short clock_rate;
  356. /* query 4 */
  357. unsigned char touch_controller_family;
  358. /* query 5 */
  359. unsigned char has_pixel_touch_threshold_adjustment:1;
  360. unsigned char f54_query5_b1__7:7;
  361. /* query 6 */
  362. unsigned char has_sensor_assignment:1;
  363. unsigned char has_interference_metric:1;
  364. unsigned char has_sense_frequency_control:1;
  365. unsigned char has_firmware_noise_mitigation:1;
  366. unsigned char has_ctrl11:1;
  367. unsigned char has_two_byte_report_rate:1;
  368. unsigned char has_one_byte_report_rate:1;
  369. unsigned char has_relaxation_control:1;
  370. /* query 7 */
  371. unsigned char curve_compensation_mode:2;
  372. unsigned char f54_query7_b2__7:6;
  373. /* query 8 */
  374. unsigned char f54_query8_b0:1;
  375. unsigned char has_iir_filter:1;
  376. unsigned char has_cmn_removal:1;
  377. unsigned char has_cmn_maximum:1;
  378. unsigned char has_touch_hysteresis:1;
  379. unsigned char has_edge_compensation:1;
  380. unsigned char has_per_frequency_noise_control:1;
  381. unsigned char has_enhanced_stretch:1;
  382. /* query 9 */
  383. unsigned char has_force_fast_relaxation:1;
  384. unsigned char has_multi_metric_state_machine:1;
  385. unsigned char has_signal_clarity:1;
  386. unsigned char has_variance_metric:1;
  387. unsigned char has_0d_relaxation_control:1;
  388. unsigned char has_0d_acquisition_control:1;
  389. unsigned char has_status:1;
  390. unsigned char has_slew_metric:1;
  391. /* queries 10 11 */
  392. unsigned char f54_query10;
  393. unsigned char f54_query11;
  394. /* query 12 */
  395. unsigned char number_of_sensing_frequencies:4;
  396. unsigned char f54_query12_b4__7:4;
  397. } __packed;
  398. unsigned char data[14];
  399. };
  400. };
  401. struct f54_control_0 {
  402. union {
  403. struct {
  404. unsigned char no_relax:1;
  405. unsigned char no_scan:1;
  406. unsigned char force_fast_relaxation:1;
  407. unsigned char startup_fast_relaxation:1;
  408. unsigned char gesture_cancels_sfr:1;
  409. unsigned char enable_energy_ratio_relaxation:1;
  410. unsigned char excessive_noise_attn_enable:1;
  411. unsigned char f54_control0_b7:1;
  412. } __packed;
  413. struct {
  414. unsigned char data[1];
  415. unsigned short address;
  416. } __packed;
  417. };
  418. };
  419. struct f54_control_1 {
  420. union {
  421. struct {
  422. unsigned char bursts_per_cluster:4;
  423. unsigned char f54_ctrl1_b4__7:4;
  424. } __packed;
  425. struct {
  426. unsigned char data[1];
  427. unsigned short address;
  428. } __packed;
  429. };
  430. };
  431. struct f54_control_2 {
  432. union {
  433. struct {
  434. unsigned short saturation_cap;
  435. } __packed;
  436. struct {
  437. unsigned char data[2];
  438. unsigned short address;
  439. } __packed;
  440. };
  441. };
  442. struct f54_control_3 {
  443. union {
  444. struct {
  445. unsigned char pixel_touch_threshold;
  446. } __packed;
  447. struct {
  448. unsigned char data[1];
  449. unsigned short address;
  450. } __packed;
  451. };
  452. };
  453. struct f54_control_4__6 {
  454. union {
  455. struct {
  456. /* control 4 */
  457. unsigned char rx_feedback_cap:2;
  458. unsigned char bias_current:2;
  459. unsigned char f54_ctrl4_b4__7:4;
  460. /* control 5 */
  461. unsigned char low_ref_cap:2;
  462. unsigned char low_ref_feedback_cap:2;
  463. unsigned char low_ref_polarity:1;
  464. unsigned char f54_ctrl5_b5__7:3;
  465. /* control 6 */
  466. unsigned char high_ref_cap:2;
  467. unsigned char high_ref_feedback_cap:2;
  468. unsigned char high_ref_polarity:1;
  469. unsigned char f54_ctrl6_b5__7:3;
  470. } __packed;
  471. struct {
  472. unsigned char data[3];
  473. unsigned short address;
  474. } __packed;
  475. };
  476. };
  477. struct f54_control_7 {
  478. union {
  479. struct {
  480. unsigned char cbc_cap:2;
  481. unsigned char cbc_polarity:2;
  482. unsigned char cbc_tx_carrier_selection:1;
  483. unsigned char f54_ctrl7_b5__7:3;
  484. } __packed;
  485. struct {
  486. unsigned char data[1];
  487. unsigned short address;
  488. } __packed;
  489. };
  490. };
  491. struct f54_control_8__9 {
  492. union {
  493. struct {
  494. /* control 8 */
  495. unsigned short integration_duration:10;
  496. unsigned short f54_ctrl8_b10__15:6;
  497. /* control 9 */
  498. unsigned char reset_duration;
  499. } __packed;
  500. struct {
  501. unsigned char data[3];
  502. unsigned short address;
  503. } __packed;
  504. };
  505. };
  506. struct f54_control_10 {
  507. union {
  508. struct {
  509. unsigned char noise_sensing_bursts_per_image:4;
  510. unsigned char f54_ctrl10_b4__7:4;
  511. } __packed;
  512. struct {
  513. unsigned char data[1];
  514. unsigned short address;
  515. } __packed;
  516. };
  517. };
  518. struct f54_control_11 {
  519. union {
  520. struct {
  521. unsigned short f54_ctrl11;
  522. } __packed;
  523. struct {
  524. unsigned char data[2];
  525. unsigned short address;
  526. } __packed;
  527. };
  528. };
  529. struct f54_control_12__13 {
  530. union {
  531. struct {
  532. /* control 12 */
  533. unsigned char slow_relaxation_rate;
  534. /* control 13 */
  535. unsigned char fast_relaxation_rate;
  536. } __packed;
  537. struct {
  538. unsigned char data[2];
  539. unsigned short address;
  540. } __packed;
  541. };
  542. };
  543. struct f54_control_14 {
  544. union {
  545. struct {
  546. unsigned char rxs_on_xaxis:1;
  547. unsigned char curve_comp_on_txs:1;
  548. unsigned char f54_ctrl14_b2__7:6;
  549. } __packed;
  550. struct {
  551. unsigned char data[1];
  552. unsigned short address;
  553. } __packed;
  554. };
  555. };
  556. struct f54_control_15n {
  557. unsigned char sensor_rx_assignment;
  558. };
  559. struct f54_control_15 {
  560. struct f54_control_15n *data;
  561. unsigned short address;
  562. unsigned char length;
  563. };
  564. struct f54_control_16n {
  565. unsigned char sensor_tx_assignment;
  566. };
  567. struct f54_control_16 {
  568. struct f54_control_16n *data;
  569. unsigned short address;
  570. unsigned char length;
  571. };
  572. struct f54_control_17n {
  573. unsigned char burst_count_b8__10:3;
  574. unsigned char disable:1;
  575. unsigned char f54_ctrl17_b4:1;
  576. unsigned char filter_bandwidth:3;
  577. };
  578. struct f54_control_17 {
  579. struct f54_control_17n *data;
  580. unsigned short address;
  581. unsigned char length;
  582. };
  583. struct f54_control_18n {
  584. unsigned char burst_count_b0__7;
  585. };
  586. struct f54_control_18 {
  587. struct f54_control_18n *data;
  588. unsigned short address;
  589. unsigned char length;
  590. };
  591. struct f54_control_19n {
  592. unsigned char stretch_duration;
  593. };
  594. struct f54_control_19 {
  595. struct f54_control_19n *data;
  596. unsigned short address;
  597. unsigned char length;
  598. };
  599. struct f54_control_20 {
  600. union {
  601. struct {
  602. unsigned char disable_noise_mitigation:1;
  603. unsigned char f54_ctrl20_b1__7:7;
  604. } __packed;
  605. struct {
  606. unsigned char data[1];
  607. unsigned short address;
  608. } __packed;
  609. };
  610. };
  611. struct f54_control_21 {
  612. union {
  613. struct {
  614. unsigned short freq_shift_noise_threshold;
  615. } __packed;
  616. struct {
  617. unsigned char data[2];
  618. unsigned short address;
  619. } __packed;
  620. };
  621. };
  622. struct f54_control_22__26 {
  623. union {
  624. struct {
  625. /* control 22 */
  626. unsigned char f54_ctrl22;
  627. /* control 23 */
  628. unsigned short medium_noise_threshold;
  629. /* control 24 */
  630. unsigned short high_noise_threshold;
  631. /* control 25 */
  632. unsigned char noise_density;
  633. /* control 26 */
  634. unsigned char frame_count;
  635. } __packed;
  636. struct {
  637. unsigned char data[7];
  638. unsigned short address;
  639. } __packed;
  640. };
  641. };
  642. struct f54_control_27 {
  643. union {
  644. struct {
  645. unsigned char iir_filter_coef;
  646. } __packed;
  647. struct {
  648. unsigned char data[1];
  649. unsigned short address;
  650. } __packed;
  651. };
  652. };
  653. struct f54_control_28 {
  654. union {
  655. struct {
  656. unsigned short quiet_threshold;
  657. } __packed;
  658. struct {
  659. unsigned char data[2];
  660. unsigned short address;
  661. } __packed;
  662. };
  663. };
  664. struct f54_control_29 {
  665. union {
  666. struct {
  667. /* control 29 */
  668. unsigned char f54_ctrl29_b0__6:7;
  669. unsigned char cmn_filter_disable:1;
  670. } __packed;
  671. struct {
  672. unsigned char data[1];
  673. unsigned short address;
  674. } __packed;
  675. };
  676. };
  677. struct f54_control_30 {
  678. union {
  679. struct {
  680. unsigned char cmn_filter_max;
  681. } __packed;
  682. struct {
  683. unsigned char data[1];
  684. unsigned short address;
  685. } __packed;
  686. };
  687. };
  688. struct f54_control_31 {
  689. union {
  690. struct {
  691. unsigned char touch_hysteresis;
  692. } __packed;
  693. struct {
  694. unsigned char data[1];
  695. unsigned short address;
  696. } __packed;
  697. };
  698. };
  699. struct f54_control_32__35 {
  700. union {
  701. struct {
  702. /* control 32 */
  703. unsigned short rx_low_edge_comp;
  704. /* control 33 */
  705. unsigned short rx_high_edge_comp;
  706. /* control 34 */
  707. unsigned short tx_low_edge_comp;
  708. /* control 35 */
  709. unsigned short tx_high_edge_comp;
  710. } __packed;
  711. struct {
  712. unsigned char data[8];
  713. unsigned short address;
  714. } __packed;
  715. };
  716. };
  717. struct f54_control_36n {
  718. unsigned char axis1_comp;
  719. };
  720. struct f54_control_36 {
  721. struct f54_control_36n *data;
  722. unsigned short address;
  723. unsigned char length;
  724. };
  725. struct f54_control_37n {
  726. unsigned char axis2_comp;
  727. };
  728. struct f54_control_37 {
  729. struct f54_control_37n *data;
  730. unsigned short address;
  731. unsigned char length;
  732. };
  733. struct f54_control_38n {
  734. unsigned char noise_control_1;
  735. };
  736. struct f54_control_38 {
  737. struct f54_control_38n *data;
  738. unsigned short address;
  739. unsigned char length;
  740. };
  741. struct f54_control_39n {
  742. unsigned char noise_control_2;
  743. };
  744. struct f54_control_39 {
  745. struct f54_control_39n *data;
  746. unsigned short address;
  747. unsigned char length;
  748. };
  749. struct f54_control_40n {
  750. unsigned char noise_control_3;
  751. };
  752. struct f54_control_40 {
  753. struct f54_control_40n *data;
  754. unsigned short address;
  755. unsigned char length;
  756. };
  757. struct f54_control_41 {
  758. union {
  759. struct {
  760. /* control 41 */
  761. unsigned char no_signal_clarity:1;
  762. unsigned char f54_ctrl41_b1__7:7;
  763. } __packed;
  764. struct {
  765. unsigned char data[1];
  766. unsigned short address;
  767. } __packed;
  768. };
  769. };
  770. struct f54_control_57 {
  771. union {
  772. struct {
  773. unsigned char cbc_cap_0d:3;
  774. unsigned char cbc_polarity_0d:1;
  775. unsigned char cbc_tx_carrier_selection_0d:1;
  776. unsigned char f54_ctrl57_b5__7:3;
  777. } __packed;
  778. struct {
  779. unsigned char data[1];
  780. unsigned short address;
  781. } __packed;
  782. };
  783. };
  784. struct f54_control {
  785. struct f54_control_0 *reg_0;
  786. struct f54_control_1 *reg_1;
  787. struct f54_control_2 *reg_2;
  788. struct f54_control_3 *reg_3;
  789. struct f54_control_4__6 *reg_4__6;
  790. struct f54_control_7 *reg_7;
  791. struct f54_control_8__9 *reg_8__9;
  792. struct f54_control_10 *reg_10;
  793. struct f54_control_11 *reg_11;
  794. struct f54_control_12__13 *reg_12__13;
  795. struct f54_control_14 *reg_14;
  796. struct f54_control_15 *reg_15;
  797. struct f54_control_16 *reg_16;
  798. struct f54_control_17 *reg_17;
  799. struct f54_control_18 *reg_18;
  800. struct f54_control_19 *reg_19;
  801. struct f54_control_20 *reg_20;
  802. struct f54_control_21 *reg_21;
  803. struct f54_control_22__26 *reg_22__26;
  804. struct f54_control_27 *reg_27;
  805. struct f54_control_28 *reg_28;
  806. struct f54_control_29 *reg_29;
  807. struct f54_control_30 *reg_30;
  808. struct f54_control_31 *reg_31;
  809. struct f54_control_32__35 *reg_32__35;
  810. struct f54_control_36 *reg_36;
  811. struct f54_control_37 *reg_37;
  812. struct f54_control_38 *reg_38;
  813. struct f54_control_39 *reg_39;
  814. struct f54_control_40 *reg_40;
  815. struct f54_control_41 *reg_41;
  816. struct f54_control_57 *reg_57;
  817. };
  818. #ifdef FACTORY_MODE
  819. #include <linux/uaccess.h>
  820. #define CMD_STR_LEN 32
  821. #define CMD_PARAM_NUM 8
  822. #define CMD_RESULT_STR_LEN 896
  823. #define FT_CMD(name, func) .cmd_name = name, .cmd_func = func
  824. #define F12_CTRL15_ADDR 0x0015
  825. enum CMD_STATUS {
  826. CMD_STATUS_WAITING = 0,
  827. CMD_STATUS_RUNNING,
  828. CMD_STATUS_OK,
  829. CMD_STATUS_FAIL,
  830. CMD_STATUS_NOT_APPLICABLE,
  831. };
  832. struct ft_cmd {
  833. const char *cmd_name;
  834. void (*cmd_func)(void);
  835. struct list_head list;
  836. };
  837. struct factory_data {
  838. struct device *fac_dev_ts;
  839. short *rawcap_data;
  840. short *delta_data;
  841. short *abscap_data;
  842. short *absdelta_data;
  843. short *trx_short;
  844. bool cmd_is_running;
  845. unsigned char cmd_state;
  846. char cmd[CMD_STR_LEN];
  847. int cmd_param[CMD_PARAM_NUM];
  848. char cmd_buff[CMD_RESULT_STR_LEN];
  849. char cmd_result[CMD_RESULT_STR_LEN];
  850. struct mutex cmd_lock;
  851. struct list_head cmd_list_head;
  852. };
  853. extern void synaptics_power_ctrl(struct synaptics_rmi4_data *rmi4_data, bool enable);
  854. static int synaptics_rmi4_f54_get_report_type(int type);
  855. static ssize_t cmd_store(struct device *dev, struct device_attribute *attr,
  856. const char *buf, size_t count);
  857. static ssize_t cmd_status_show(struct device *dev,
  858. struct device_attribute *attr, char *buf);
  859. static ssize_t cmd_result_show(struct device *dev,
  860. struct device_attribute *attr, char *buf);
  861. static ssize_t cmd_list_show(struct device *dev,
  862. struct device_attribute *attr, char *buf);
  863. static DEVICE_ATTR(cmd, S_IWUSR | S_IWGRP, NULL, cmd_store);
  864. static DEVICE_ATTR(cmd_status, S_IRUGO, cmd_status_show, NULL);
  865. static DEVICE_ATTR(cmd_result, S_IRUGO, cmd_result_show, NULL);
  866. static DEVICE_ATTR(cmd_list, S_IRUGO, cmd_list_show, NULL);
  867. static struct attribute *cmd_attributes[] = {
  868. &dev_attr_cmd.attr,
  869. &dev_attr_cmd_status.attr,
  870. &dev_attr_cmd_result.attr,
  871. &dev_attr_cmd_list.attr,
  872. NULL,
  873. };
  874. static struct attribute_group cmd_attr_group = {
  875. .attrs = cmd_attributes,
  876. };
  877. static void fw_update(void);
  878. static void get_fw_ver_bin(void);
  879. static void get_fw_ver_ic(void);
  880. static void get_fac_fw_ver_bin(void);
  881. static void get_config_ver(void);
  882. static void get_threshold(void);
  883. static void module_off_master(void);
  884. static void module_on_master(void);
  885. static void get_chip_vendor(void);
  886. static void get_chip_name(void);
  887. static void get_x_num(void);
  888. static void get_y_num(void);
  889. static void get_rawcap(void);
  890. static void run_rawcap_read(void);
  891. static void get_delta(void);
  892. static void run_delta_read(void);
  893. static void run_abscap_read(void);
  894. static void run_absdelta_read(void);
  895. static void run_trx_short_test(void);
  896. static void hover_enable(void);
  897. static void hover_no_sleep_enable(void);
  898. #ifdef CONFIG_GLOVE_TOUCH
  899. static void glove_mode(void);
  900. static void clear_cover_mode(void);
  901. static void get_glove_sensitivity(void);
  902. static void fast_glove_mode(void);
  903. #endif
  904. #ifdef TSP_BOOSTER
  905. static void boost_level(void);
  906. #endif
  907. static void switch_sel(void);
  908. static void not_support_cmd(void);
  909. struct ft_cmd ft_cmds[] = {
  910. {FT_CMD("fw_update", fw_update),},
  911. {FT_CMD("get_fw_ver_bin", get_fw_ver_bin),},
  912. {FT_CMD("get_fw_ver_ic", get_fw_ver_ic),},
  913. {FT_CMD("get_fac_fw_ver_bin", get_fac_fw_ver_bin),},
  914. {FT_CMD("get_config_ver", get_config_ver),},
  915. {FT_CMD("get_threshold", get_threshold),},
  916. {FT_CMD("module_off_master", module_off_master),},
  917. {FT_CMD("module_on_master", module_on_master),},
  918. {FT_CMD("module_off_slave", not_support_cmd),},
  919. {FT_CMD("module_on_slave", not_support_cmd),},
  920. {FT_CMD("get_chip_vendor", get_chip_vendor),},
  921. {FT_CMD("get_chip_name", get_chip_name),},
  922. {FT_CMD("get_x_num", get_x_num),},
  923. {FT_CMD("get_y_num", get_y_num),},
  924. {FT_CMD("get_rawcap", get_rawcap),},
  925. {FT_CMD("run_rawcap_read", run_rawcap_read),},
  926. {FT_CMD("get_delta", get_delta),},
  927. {FT_CMD("run_delta_read", run_delta_read),},
  928. {FT_CMD("run_abscap_read", run_abscap_read),},
  929. {FT_CMD("run_absdelta_read", run_absdelta_read),},
  930. {FT_CMD("run_trx_short_test", run_trx_short_test),},
  931. {FT_CMD("hover_enable", hover_enable),},
  932. {FT_CMD("hover_no_sleep_enable", hover_no_sleep_enable),},
  933. #ifdef CONFIG_GLOVE_TOUCH
  934. {FT_CMD("glove_mode", glove_mode),},
  935. {FT_CMD("clear_cover_mode", clear_cover_mode),},
  936. {FT_CMD("get_glove_sensitivity", get_glove_sensitivity),},
  937. {FT_CMD("fast_glove_mode", fast_glove_mode),},
  938. #endif
  939. #ifdef TSP_BOOSTER
  940. {FT_CMD("boost_level", boost_level),},
  941. #endif
  942. {FT_CMD("switch_sel", switch_sel),},
  943. {FT_CMD("not_support_cmd", not_support_cmd),},
  944. };
  945. #endif
  946. struct synaptics_rmi4_f54_handle {
  947. bool no_auto_cal;
  948. unsigned char status;
  949. unsigned char intr_mask;
  950. unsigned char intr_reg_num;
  951. unsigned char *report_data;
  952. unsigned short query_base_addr;
  953. unsigned short control_base_addr;
  954. unsigned short data_base_addr;
  955. unsigned short command_base_addr;
  956. unsigned short fifoindex;
  957. unsigned int report_size;
  958. unsigned int data_buffer_size;
  959. enum f54_report_types report_type;
  960. struct mutex status_mutex;
  961. struct mutex data_mutex;
  962. struct mutex control_mutex;
  963. struct f54_query query;
  964. struct f54_control control;
  965. #ifdef FACTORY_MODE
  966. struct factory_data *factory_data;
  967. #endif
  968. struct kobject *attr_dir;
  969. struct hrtimer watchdog;
  970. struct work_struct timeout_work;
  971. struct delayed_work status_work;
  972. struct workqueue_struct *status_workqueue;
  973. struct synaptics_rmi4_exp_fn_ptr *fn_ptr;
  974. struct synaptics_rmi4_data *rmi4_data;
  975. };
  976. show_prototype(status)
  977. show_prototype(report_size)
  978. show_store_prototype(no_auto_cal)
  979. show_store_prototype(report_type)
  980. show_store_prototype(fifoindex)
  981. store_prototype(do_preparation)
  982. store_prototype(get_report)
  983. store_prototype(force_cal)
  984. show_prototype(num_of_rx_electrodes)
  985. show_prototype(num_of_tx_electrodes)
  986. show_prototype(has_image16)
  987. show_prototype(has_image8)
  988. show_prototype(has_baseline)
  989. show_prototype(clock_rate)
  990. show_prototype(touch_controller_family)
  991. show_prototype(has_pixel_touch_threshold_adjustment)
  992. show_prototype(has_sensor_assignment)
  993. show_prototype(has_interference_metric)
  994. show_prototype(has_sense_frequency_control)
  995. show_prototype(has_firmware_noise_mitigation)
  996. show_prototype(has_two_byte_report_rate)
  997. show_prototype(has_one_byte_report_rate)
  998. show_prototype(has_relaxation_control)
  999. show_prototype(curve_compensation_mode)
  1000. show_prototype(has_iir_filter)
  1001. show_prototype(has_cmn_removal)
  1002. show_prototype(has_cmn_maximum)
  1003. show_prototype(has_touch_hysteresis)
  1004. show_prototype(has_edge_compensation)
  1005. show_prototype(has_per_frequency_noise_control)
  1006. show_prototype(has_signal_clarity)
  1007. show_prototype(number_of_sensing_frequencies)
  1008. show_store_prototype(no_relax)
  1009. show_store_prototype(no_scan)
  1010. show_store_prototype(bursts_per_cluster)
  1011. show_store_prototype(saturation_cap)
  1012. show_store_prototype(pixel_touch_threshold)
  1013. show_store_prototype(rx_feedback_cap)
  1014. show_store_prototype(low_ref_cap)
  1015. show_store_prototype(low_ref_feedback_cap)
  1016. show_store_prototype(low_ref_polarity)
  1017. show_store_prototype(high_ref_cap)
  1018. show_store_prototype(high_ref_feedback_cap)
  1019. show_store_prototype(high_ref_polarity)
  1020. show_store_prototype(cbc_cap)
  1021. show_store_prototype(cbc_polarity)
  1022. show_store_prototype(cbc_tx_carrier_selection)
  1023. show_store_prototype(integration_duration)
  1024. show_store_prototype(reset_duration)
  1025. show_store_prototype(noise_sensing_bursts_per_image)
  1026. show_store_prototype(slow_relaxation_rate)
  1027. show_store_prototype(fast_relaxation_rate)
  1028. show_store_prototype(rxs_on_xaxis)
  1029. show_store_prototype(curve_comp_on_txs)
  1030. show_prototype(sensor_rx_assignment)
  1031. show_prototype(sensor_tx_assignment)
  1032. show_prototype(burst_count)
  1033. show_prototype(disable)
  1034. show_prototype(filter_bandwidth)
  1035. show_prototype(stretch_duration)
  1036. show_store_prototype(disable_noise_mitigation)
  1037. show_store_prototype(freq_shift_noise_threshold)
  1038. show_store_prototype(medium_noise_threshold)
  1039. show_store_prototype(high_noise_threshold)
  1040. show_store_prototype(noise_density)
  1041. show_store_prototype(frame_count)
  1042. show_store_prototype(iir_filter_coef)
  1043. show_store_prototype(quiet_threshold)
  1044. show_store_prototype(cmn_filter_disable)
  1045. show_store_prototype(cmn_filter_max)
  1046. show_store_prototype(touch_hysteresis)
  1047. show_store_prototype(rx_low_edge_comp)
  1048. show_store_prototype(rx_high_edge_comp)
  1049. show_store_prototype(tx_low_edge_comp)
  1050. show_store_prototype(tx_high_edge_comp)
  1051. show_store_prototype(axis1_comp)
  1052. show_store_prototype(axis2_comp)
  1053. show_prototype(noise_control_1)
  1054. show_prototype(noise_control_2)
  1055. show_prototype(noise_control_3)
  1056. show_store_prototype(no_signal_clarity)
  1057. static ssize_t synaptics_rmi4_f54_data_read(struct file *data_file,
  1058. struct kobject *kobj, struct bin_attribute *attributes,
  1059. char *buf, loff_t pos, size_t count);
  1060. static struct attribute *attrs[] = {
  1061. attrify(status),
  1062. attrify(report_size),
  1063. attrify(no_auto_cal),
  1064. attrify(report_type),
  1065. attrify(fifoindex),
  1066. attrify(do_preparation),
  1067. attrify(get_report),
  1068. attrify(force_cal),
  1069. attrify(num_of_rx_electrodes),
  1070. attrify(num_of_tx_electrodes),
  1071. attrify(has_image16),
  1072. attrify(has_image8),
  1073. attrify(has_baseline),
  1074. attrify(clock_rate),
  1075. attrify(touch_controller_family),
  1076. attrify(has_pixel_touch_threshold_adjustment),
  1077. attrify(has_sensor_assignment),
  1078. attrify(has_interference_metric),
  1079. attrify(has_sense_frequency_control),
  1080. attrify(has_firmware_noise_mitigation),
  1081. attrify(has_two_byte_report_rate),
  1082. attrify(has_one_byte_report_rate),
  1083. attrify(has_relaxation_control),
  1084. attrify(curve_compensation_mode),
  1085. attrify(has_iir_filter),
  1086. attrify(has_cmn_removal),
  1087. attrify(has_cmn_maximum),
  1088. attrify(has_touch_hysteresis),
  1089. attrify(has_edge_compensation),
  1090. attrify(has_per_frequency_noise_control),
  1091. attrify(has_signal_clarity),
  1092. attrify(number_of_sensing_frequencies),
  1093. NULL,
  1094. };
  1095. static struct attribute_group attr_group = GROUP(attrs);
  1096. static struct attribute *attrs_reg_0[] = {
  1097. attrify(no_relax),
  1098. attrify(no_scan),
  1099. NULL,
  1100. };
  1101. static struct attribute *attrs_reg_1[] = {
  1102. attrify(bursts_per_cluster),
  1103. NULL,
  1104. };
  1105. static struct attribute *attrs_reg_2[] = {
  1106. attrify(saturation_cap),
  1107. NULL,
  1108. };
  1109. static struct attribute *attrs_reg_3[] = {
  1110. attrify(pixel_touch_threshold),
  1111. NULL,
  1112. };
  1113. static struct attribute *attrs_reg_4__6[] = {
  1114. attrify(rx_feedback_cap),
  1115. attrify(low_ref_cap),
  1116. attrify(low_ref_feedback_cap),
  1117. attrify(low_ref_polarity),
  1118. attrify(high_ref_cap),
  1119. attrify(high_ref_feedback_cap),
  1120. attrify(high_ref_polarity),
  1121. NULL,
  1122. };
  1123. static struct attribute *attrs_reg_7[] = {
  1124. attrify(cbc_cap),
  1125. attrify(cbc_polarity),
  1126. attrify(cbc_tx_carrier_selection),
  1127. NULL,
  1128. };
  1129. static struct attribute *attrs_reg_8__9[] = {
  1130. attrify(integration_duration),
  1131. attrify(reset_duration),
  1132. NULL,
  1133. };
  1134. static struct attribute *attrs_reg_10[] = {
  1135. attrify(noise_sensing_bursts_per_image),
  1136. NULL,
  1137. };
  1138. static struct attribute *attrs_reg_11[] = {
  1139. NULL,
  1140. };
  1141. static struct attribute *attrs_reg_12__13[] = {
  1142. attrify(slow_relaxation_rate),
  1143. attrify(fast_relaxation_rate),
  1144. NULL,
  1145. };
  1146. static struct attribute *attrs_reg_14__16[] = {
  1147. attrify(rxs_on_xaxis),
  1148. attrify(curve_comp_on_txs),
  1149. attrify(sensor_rx_assignment),
  1150. attrify(sensor_tx_assignment),
  1151. NULL,
  1152. };
  1153. static struct attribute *attrs_reg_17__19[] = {
  1154. attrify(burst_count),
  1155. attrify(disable),
  1156. attrify(filter_bandwidth),
  1157. attrify(stretch_duration),
  1158. NULL,
  1159. };
  1160. static struct attribute *attrs_reg_20[] = {
  1161. attrify(disable_noise_mitigation),
  1162. NULL,
  1163. };
  1164. static struct attribute *attrs_reg_21[] = {
  1165. attrify(freq_shift_noise_threshold),
  1166. NULL,
  1167. };
  1168. static struct attribute *attrs_reg_22__26[] = {
  1169. attrify(medium_noise_threshold),
  1170. attrify(high_noise_threshold),
  1171. attrify(noise_density),
  1172. attrify(frame_count),
  1173. NULL,
  1174. };
  1175. static struct attribute *attrs_reg_27[] = {
  1176. attrify(iir_filter_coef),
  1177. NULL,
  1178. };
  1179. static struct attribute *attrs_reg_28[] = {
  1180. attrify(quiet_threshold),
  1181. NULL,
  1182. };
  1183. static struct attribute *attrs_reg_29[] = {
  1184. attrify(cmn_filter_disable),
  1185. NULL,
  1186. };
  1187. static struct attribute *attrs_reg_30[] = {
  1188. attrify(cmn_filter_max),
  1189. NULL,
  1190. };
  1191. static struct attribute *attrs_reg_31[] = {
  1192. attrify(touch_hysteresis),
  1193. NULL,
  1194. };
  1195. static struct attribute *attrs_reg_32__35[] = {
  1196. attrify(rx_low_edge_comp),
  1197. attrify(rx_high_edge_comp),
  1198. attrify(tx_low_edge_comp),
  1199. attrify(tx_high_edge_comp),
  1200. NULL,
  1201. };
  1202. static struct attribute *attrs_reg_36[] = {
  1203. attrify(axis1_comp),
  1204. NULL,
  1205. };
  1206. static struct attribute *attrs_reg_37[] = {
  1207. attrify(axis2_comp),
  1208. NULL,
  1209. };
  1210. static struct attribute *attrs_reg_38__40[] = {
  1211. attrify(noise_control_1),
  1212. attrify(noise_control_2),
  1213. attrify(noise_control_3),
  1214. NULL,
  1215. };
  1216. static struct attribute *attrs_reg_41[] = {
  1217. attrify(no_signal_clarity),
  1218. NULL,
  1219. };
  1220. static struct attribute_group attrs_ctrl_regs[] = {
  1221. GROUP(attrs_reg_0),
  1222. GROUP(attrs_reg_1),
  1223. GROUP(attrs_reg_2),
  1224. GROUP(attrs_reg_3),
  1225. GROUP(attrs_reg_4__6),
  1226. GROUP(attrs_reg_7),
  1227. GROUP(attrs_reg_8__9),
  1228. GROUP(attrs_reg_10),
  1229. GROUP(attrs_reg_11),
  1230. GROUP(attrs_reg_12__13),
  1231. GROUP(attrs_reg_14__16),
  1232. GROUP(attrs_reg_17__19),
  1233. GROUP(attrs_reg_20),
  1234. GROUP(attrs_reg_21),
  1235. GROUP(attrs_reg_22__26),
  1236. GROUP(attrs_reg_27),
  1237. GROUP(attrs_reg_28),
  1238. GROUP(attrs_reg_29),
  1239. GROUP(attrs_reg_30),
  1240. GROUP(attrs_reg_31),
  1241. GROUP(attrs_reg_32__35),
  1242. GROUP(attrs_reg_36),
  1243. GROUP(attrs_reg_37),
  1244. GROUP(attrs_reg_38__40),
  1245. GROUP(attrs_reg_41),
  1246. };
  1247. static bool attrs_ctrl_regs_exist[ARRAY_SIZE(attrs_ctrl_regs)];
  1248. static struct bin_attribute dev_report_data = {
  1249. .attr = {
  1250. .name = "report_data",
  1251. .mode = S_IRUGO,
  1252. },
  1253. .size = 0,
  1254. .read = synaptics_rmi4_f54_data_read,
  1255. };
  1256. static struct synaptics_rmi4_f54_handle *f54;
  1257. static bool is_report_type_valid(enum f54_report_types report_type)
  1258. {
  1259. switch (report_type) {
  1260. case F54_8BIT_IMAGE:
  1261. case F54_16BIT_IMAGE:
  1262. case F54_RAW_16BIT_IMAGE:
  1263. case F54_HIGH_RESISTANCE:
  1264. case F54_TX_TO_TX_SHORT:
  1265. case F54_RX_TO_RX1:
  1266. case F54_TRUE_BASELINE:
  1267. case F54_FULL_RAW_CAP_MIN_MAX:
  1268. case F54_RX_OPENS1:
  1269. case F54_TX_OPEN:
  1270. case F54_TX_TO_GROUND:
  1271. case F54_RX_TO_RX2:
  1272. case F54_RX_OPENS2:
  1273. case F54_FULL_RAW_CAP:
  1274. case F54_FULL_RAW_CAP_RX_COUPLING_COMP:
  1275. case F54_SENSOR_SPEED:
  1276. case F54_ADC_RANGE:
  1277. case F54_TREX_OPENS:
  1278. case F54_TREX_TO_GND:
  1279. case F54_TREX_SHORTS:
  1280. case F54_ABS_RAW_CAP:
  1281. case F54_ABS_DELTA_CAP:
  1282. return true;
  1283. break;
  1284. default:
  1285. f54->report_type = INVALID_REPORT_TYPE;
  1286. f54->report_size = 0;
  1287. return false;
  1288. }
  1289. }
  1290. static void set_report_size(void)
  1291. {
  1292. int retval;
  1293. unsigned char rx = f54->rmi4_data->num_of_rx;
  1294. unsigned char tx = f54->rmi4_data->num_of_tx;
  1295. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1296. switch (f54->report_type) {
  1297. case F54_8BIT_IMAGE:
  1298. f54->report_size = rx * tx;
  1299. break;
  1300. case F54_16BIT_IMAGE:
  1301. case F54_RAW_16BIT_IMAGE:
  1302. case F54_TRUE_BASELINE:
  1303. case F54_FULL_RAW_CAP:
  1304. case F54_FULL_RAW_CAP_RX_COUPLING_COMP:
  1305. case F54_SENSOR_SPEED:
  1306. f54->report_size = 2 * rx * tx;
  1307. break;
  1308. case F54_HIGH_RESISTANCE:
  1309. f54->report_size = HIGH_RESISTANCE_DATA_SIZE;
  1310. break;
  1311. case F54_TX_TO_TX_SHORT:
  1312. case F54_TX_OPEN:
  1313. case F54_TX_TO_GROUND:
  1314. f54->report_size = (tx + 7) / 8;
  1315. break;
  1316. case F54_RX_TO_RX1:
  1317. case F54_RX_OPENS1:
  1318. if (rx < tx)
  1319. f54->report_size = 2 * rx * rx;
  1320. else
  1321. f54->report_size = 2 * rx * tx;
  1322. break;
  1323. case F54_FULL_RAW_CAP_MIN_MAX:
  1324. f54->report_size = FULL_RAW_CAP_MIN_MAX_DATA_SIZE;
  1325. break;
  1326. case F54_RX_TO_RX2:
  1327. case F54_RX_OPENS2:
  1328. if (rx <= tx)
  1329. f54->report_size = 0;
  1330. else
  1331. f54->report_size = 2 * rx * (rx - tx);
  1332. break;
  1333. case F54_ADC_RANGE:
  1334. if (f54->query.has_signal_clarity) {
  1335. mutex_lock(&f54->control_mutex);
  1336. retval = f54->fn_ptr->read(rmi4_data,
  1337. f54->control.reg_41->address,
  1338. f54->control.reg_41->data,
  1339. sizeof(f54->control.reg_41->data));
  1340. mutex_unlock(&f54->control_mutex);
  1341. if (retval < 0) {
  1342. dev_dbg(&rmi4_data->i2c_client->dev,
  1343. "%s: Failed to read control reg_41\n",
  1344. __func__);
  1345. f54->report_size = 0;
  1346. break;
  1347. }
  1348. if (!f54->control.reg_41->no_signal_clarity) {
  1349. if (tx % 4)
  1350. tx += 4 - (tx % 4);
  1351. }
  1352. }
  1353. f54->report_size = 2 * rx * tx;
  1354. break;
  1355. case F54_TREX_OPENS:
  1356. case F54_TREX_TO_GND:
  1357. case F54_TREX_SHORTS:
  1358. f54->report_size = TREX_DATA_SIZE;
  1359. break;
  1360. case F54_ABS_RAW_CAP:
  1361. case F54_ABS_DELTA_CAP:
  1362. f54->report_size = 4 * (rx + tx);
  1363. break;
  1364. default:
  1365. f54->report_size = 0;
  1366. }
  1367. return;
  1368. }
  1369. static int set_interrupt(bool set)
  1370. {
  1371. int retval;
  1372. unsigned char ii;
  1373. unsigned char zero = 0x00;
  1374. unsigned char *intr_mask;
  1375. unsigned short f01_ctrl_reg;
  1376. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1377. intr_mask = rmi4_data->intr_mask;
  1378. f01_ctrl_reg = rmi4_data->f01_ctrl_base_addr + 1 + f54->intr_reg_num;
  1379. if (!set) {
  1380. retval = f54->fn_ptr->write(rmi4_data,
  1381. f01_ctrl_reg,
  1382. &zero,
  1383. sizeof(zero));
  1384. if (retval < 0)
  1385. return retval;
  1386. }
  1387. for (ii = 0; ii < rmi4_data->num_of_intr_regs; ii++) {
  1388. if (intr_mask[ii] != 0x00) {
  1389. f01_ctrl_reg = rmi4_data->f01_ctrl_base_addr + 1 + ii;
  1390. if (set) {
  1391. retval = f54->fn_ptr->write(rmi4_data,
  1392. f01_ctrl_reg,
  1393. &zero,
  1394. sizeof(zero));
  1395. if (retval < 0)
  1396. return retval;
  1397. } else {
  1398. retval = f54->fn_ptr->write(rmi4_data,
  1399. f01_ctrl_reg,
  1400. &(intr_mask[ii]),
  1401. sizeof(intr_mask[ii]));
  1402. if (retval < 0)
  1403. return retval;
  1404. }
  1405. }
  1406. }
  1407. f01_ctrl_reg = rmi4_data->f01_ctrl_base_addr + 1 + f54->intr_reg_num;
  1408. if (set) {
  1409. retval = f54->fn_ptr->write(rmi4_data,
  1410. f01_ctrl_reg,
  1411. &f54->intr_mask,
  1412. 1);
  1413. if (retval < 0)
  1414. return retval;
  1415. }
  1416. return 0;
  1417. }
  1418. static int do_preparation(void)
  1419. {
  1420. int retval;
  1421. unsigned char value;
  1422. unsigned char command;
  1423. unsigned char timeout_count;
  1424. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1425. if (f54->query.touch_controller_family == 1) {
  1426. value = 0;
  1427. retval = f54->fn_ptr->write(rmi4_data,
  1428. f54->control.reg_7->address,
  1429. &value,
  1430. sizeof(f54->control.reg_7->data));
  1431. if (retval < 0) {
  1432. dev_err(&rmi4_data->i2c_client->dev,
  1433. "%s: Failed to disable CBC\n",
  1434. __func__);
  1435. return retval;
  1436. }
  1437. }
  1438. #if 0 /* Below codes are just needed for 0D */
  1439. if (f54->query.has_0d_acquisition_control) {
  1440. value = 0;
  1441. retval = f54->fn_ptr->write(rmi4_data,
  1442. f54->control.reg_57->address,
  1443. &value,
  1444. sizeof(f54->control.reg_57->data));
  1445. if (retval < 0) {
  1446. dev_err(&rmi4_data->i2c_client->dev,
  1447. "%s: Failed to disable 0D CBC\n",
  1448. __func__);
  1449. return retval;
  1450. }
  1451. }
  1452. #endif
  1453. if (f54->query.has_signal_clarity) {
  1454. value = 1;
  1455. retval = f54->fn_ptr->write(rmi4_data,
  1456. f54->control.reg_41->address,
  1457. &value,
  1458. sizeof(f54->control.reg_41->data));
  1459. if (retval < 0) {
  1460. dev_err(&rmi4_data->i2c_client->dev,
  1461. "%s: Failed to disable signal clarity\n",
  1462. __func__);
  1463. return retval;
  1464. }
  1465. }
  1466. command = (unsigned char)COMMAND_FORCE_UPDATE;
  1467. retval = f54->fn_ptr->write(rmi4_data,
  1468. f54->command_base_addr,
  1469. &command,
  1470. sizeof(command));
  1471. if (retval < 0) {
  1472. dev_err(&rmi4_data->i2c_client->dev,
  1473. "%s: Failed to write force update command\n",
  1474. __func__);
  1475. return retval;
  1476. }
  1477. timeout_count = 0;
  1478. do {
  1479. retval = f54->fn_ptr->read(rmi4_data,
  1480. f54->command_base_addr,
  1481. &value,
  1482. sizeof(value));
  1483. if (retval < 0) {
  1484. dev_err(&rmi4_data->i2c_client->dev,
  1485. "%s: Failed to read command register\n",
  1486. __func__);
  1487. return retval;
  1488. }
  1489. if (value == 0x00)
  1490. break;
  1491. msleep(100);
  1492. timeout_count++;
  1493. } while (timeout_count < FORCE_TIMEOUT_100MS);
  1494. if (timeout_count == FORCE_TIMEOUT_100MS) {
  1495. dev_err(&rmi4_data->i2c_client->dev,
  1496. "%s: Timed out waiting for force update\n",
  1497. __func__);
  1498. return -ETIMEDOUT;
  1499. }
  1500. command = (unsigned char)COMMAND_FORCE_CAL;
  1501. retval = f54->fn_ptr->write(rmi4_data,
  1502. f54->command_base_addr,
  1503. &command,
  1504. sizeof(command));
  1505. if (retval < 0) {
  1506. dev_err(&rmi4_data->i2c_client->dev,
  1507. "%s: Failed to write force cal command\n",
  1508. __func__);
  1509. return retval;
  1510. }
  1511. timeout_count = 0;
  1512. do {
  1513. retval = f54->fn_ptr->read(rmi4_data,
  1514. f54->command_base_addr,
  1515. &value,
  1516. sizeof(value));
  1517. if (retval < 0) {
  1518. dev_err(&rmi4_data->i2c_client->dev,
  1519. "%s: Failed to read command register\n",
  1520. __func__);
  1521. return retval;
  1522. }
  1523. if (value == 0x00)
  1524. break;
  1525. msleep(100);
  1526. timeout_count++;
  1527. } while (timeout_count < FORCE_TIMEOUT_100MS);
  1528. if (timeout_count == FORCE_TIMEOUT_100MS) {
  1529. dev_err(&rmi4_data->i2c_client->dev,
  1530. "%s: Timed out waiting for force cal\n",
  1531. __func__);
  1532. return -ETIMEDOUT;
  1533. }
  1534. return 0;
  1535. }
  1536. #ifdef WATCHDOG_HRTIMER
  1537. static void timeout_set_status(struct work_struct *work)
  1538. {
  1539. int retval;
  1540. unsigned char command;
  1541. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1542. dev_info(&rmi4_data->i2c_client->dev, "[synaptics] %s\n", __func__);
  1543. mutex_lock(&f54->status_mutex);
  1544. if (f54->status == STATUS_BUSY) {
  1545. retval = f54->fn_ptr->read(rmi4_data,
  1546. f54->command_base_addr,
  1547. &command,
  1548. sizeof(command));
  1549. if (retval < 0) {
  1550. dev_err(&rmi4_data->i2c_client->dev,
  1551. "%s: Failed to read command register\n",
  1552. __func__);
  1553. f54->status = STATUS_ERROR;
  1554. } else if (command & COMMAND_GET_REPORT) {
  1555. dev_err(&rmi4_data->i2c_client->dev,
  1556. "%s: Report type not supported by FW\n",
  1557. __func__);
  1558. f54->status = STATUS_ERROR;
  1559. } else {
  1560. queue_delayed_work(f54->status_workqueue,
  1561. &f54->status_work,
  1562. 0);
  1563. mutex_unlock(&f54->status_mutex);
  1564. return;
  1565. }
  1566. f54->report_type = INVALID_REPORT_TYPE;
  1567. f54->report_size = 0;
  1568. }
  1569. mutex_unlock(&f54->status_mutex);
  1570. /* read fail : need ic reset */
  1571. if (f54->status == STATUS_ERROR) {
  1572. if (rmi4_data->touch_stopped) {
  1573. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  1574. __func__);
  1575. f54->status = STATUS_IDLE;
  1576. return;
  1577. }
  1578. dev_err(&rmi4_data->i2c_client->dev, "%s: reset device\n",
  1579. __func__);
  1580. retval = rmi4_data->reset_device(rmi4_data);
  1581. if (retval < 0) {
  1582. dev_err(&rmi4_data->i2c_client->dev,
  1583. "%s: Failed to issue reset command, error = %d\n",
  1584. __func__, retval);
  1585. }
  1586. mutex_lock(&f54->status_mutex);
  1587. f54->status = STATUS_IDLE;
  1588. mutex_unlock(&f54->status_mutex);
  1589. }
  1590. return;
  1591. }
  1592. static enum hrtimer_restart get_report_timeout(struct hrtimer *timer)
  1593. {
  1594. schedule_work(&(f54->timeout_work));
  1595. return HRTIMER_NORESTART;
  1596. }
  1597. #endif
  1598. #ifdef RAW_HEX
  1599. static void print_raw_hex_report(void)
  1600. {
  1601. unsigned int ii;
  1602. pr_info("%s: Report data (raw hex)\n", __func__);
  1603. switch (f54->report_type) {
  1604. case F54_16BIT_IMAGE:
  1605. case F54_RAW_16BIT_IMAGE:
  1606. case F54_HIGH_RESISTANCE:
  1607. case F54_TRUE_BASELINE:
  1608. case F54_FULL_RAW_CAP_MIN_MAX:
  1609. case F54_FULL_RAW_CAP:
  1610. case F54_FULL_RAW_CAP_RX_COUPLING_COMP:
  1611. case F54_SENSOR_SPEED:
  1612. case F54_ADC_RANGE:
  1613. for (ii = 0; ii < f54->report_size; ii += 2) {
  1614. pr_info("%03d: 0x%02x%02x\n",
  1615. ii / 2,
  1616. f54->report_data[ii + 1],
  1617. f54->report_data[ii]);
  1618. }
  1619. break;
  1620. case F54_ABS_RAW_CAP:
  1621. case F54_ABS_DELTA_CAP:
  1622. for (ii = 0; ii < f54->report_size; ii += 4) {
  1623. pr_info("%03d: 0x%02x%02x%02x%02x\n",
  1624. ii / 4,
  1625. f54->report_data[ii + 3],
  1626. f54->report_data[ii + 2],
  1627. f54->report_data[ii + 1],
  1628. f54->report_data[ii]);
  1629. }
  1630. break;
  1631. default:
  1632. for (ii = 0; ii < f54->report_size; ii++)
  1633. pr_info("%03d: 0x%02x\n", ii, f54->report_data[ii]);
  1634. break;
  1635. }
  1636. return;
  1637. }
  1638. #endif
  1639. #ifdef HUMAN_READABLE
  1640. static void print_image_report(void)
  1641. {
  1642. unsigned int ii;
  1643. unsigned int jj;
  1644. short *report_data;
  1645. switch (f54->report_type) {
  1646. case F54_16BIT_IMAGE:
  1647. case F54_RAW_16BIT_IMAGE:
  1648. case F54_TRUE_BASELINE:
  1649. case F54_FULL_RAW_CAP:
  1650. case F54_FULL_RAW_CAP_RX_COUPLING_COMP:
  1651. pr_info("%s: Report data (image)\n", __func__);
  1652. report_data = (short *)f54->report_data;
  1653. for (ii = 0; ii < f54->rmi4_data->num_of_tx; ii++) {
  1654. for (jj = 0; jj < f54->rmi4_data->num_of_rx; jj++) {
  1655. if (*report_data < -64)
  1656. pr_cont(".");
  1657. else if (*report_data < 0)
  1658. pr_cont("-");
  1659. else if (*report_data > 64)
  1660. pr_cont("*");
  1661. else if (*report_data > 0)
  1662. pr_cont("+");
  1663. else
  1664. pr_cont("0");
  1665. report_data++;
  1666. }
  1667. pr_info("");
  1668. }
  1669. pr_info("%s: End of report\n", __func__);
  1670. break;
  1671. default:
  1672. pr_info("%s: Image not supported for report type %d\n",
  1673. __func__, f54->report_type);
  1674. }
  1675. return;
  1676. }
  1677. #endif
  1678. static void free_control_mem(void)
  1679. {
  1680. struct f54_control control = f54->control;
  1681. kfree(control.reg_0);
  1682. kfree(control.reg_1);
  1683. kfree(control.reg_2);
  1684. kfree(control.reg_3);
  1685. kfree(control.reg_4__6);
  1686. kfree(control.reg_7);
  1687. kfree(control.reg_8__9);
  1688. kfree(control.reg_10);
  1689. kfree(control.reg_11);
  1690. kfree(control.reg_12__13);
  1691. kfree(control.reg_14);
  1692. kfree(control.reg_15);
  1693. kfree(control.reg_16);
  1694. kfree(control.reg_17);
  1695. kfree(control.reg_18);
  1696. kfree(control.reg_19);
  1697. kfree(control.reg_20);
  1698. kfree(control.reg_21);
  1699. kfree(control.reg_22__26);
  1700. kfree(control.reg_27);
  1701. kfree(control.reg_28);
  1702. kfree(control.reg_29);
  1703. kfree(control.reg_30);
  1704. kfree(control.reg_31);
  1705. kfree(control.reg_32__35);
  1706. kfree(control.reg_36);
  1707. kfree(control.reg_37);
  1708. kfree(control.reg_38);
  1709. kfree(control.reg_39);
  1710. kfree(control.reg_40);
  1711. kfree(control.reg_41);
  1712. return;
  1713. }
  1714. static void remove_sysfs(void)
  1715. {
  1716. int reg_num;
  1717. sysfs_remove_bin_file(f54->attr_dir, &dev_report_data);
  1718. sysfs_remove_group(f54->attr_dir, &attr_group);
  1719. for (reg_num = 0; reg_num < ARRAY_SIZE(attrs_ctrl_regs); reg_num++)
  1720. sysfs_remove_group(f54->attr_dir, &attrs_ctrl_regs[reg_num]);
  1721. kobject_put(f54->attr_dir);
  1722. return;
  1723. }
  1724. #ifdef FACTORY_MODE
  1725. static void set_default_result(struct factory_data *data)
  1726. {
  1727. char delim = ':';
  1728. memset(data->cmd_buff, 0x00, sizeof(data->cmd_buff));
  1729. memset(data->cmd_result, 0x00, sizeof(data->cmd_result));
  1730. memcpy(data->cmd_result, data->cmd, strlen(data->cmd));
  1731. strncat(data->cmd_result, &delim, 1);
  1732. return;
  1733. }
  1734. static void set_cmd_result(struct factory_data *data, char *buf, int length)
  1735. {
  1736. strncat(data->cmd_result, buf, length);
  1737. return;
  1738. }
  1739. static ssize_t cmd_store(struct device *dev, struct device_attribute *attr,
  1740. const char *buf, size_t count)
  1741. {
  1742. unsigned char param_cnt = 0;
  1743. char *start;
  1744. char *end;
  1745. char *pos;
  1746. char delim = ',';
  1747. char buffer[CMD_STR_LEN];
  1748. bool cmd_found = false;
  1749. int *param;
  1750. int length;
  1751. struct ft_cmd *ft_cmd_ptr;
  1752. struct factory_data *data = f54->factory_data;
  1753. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1754. #ifdef TSP_PATTERN_TRACKING_METHOD
  1755. if (rmi4_data->pattern_data.is_working) {
  1756. dev_err(&rmi4_data->i2c_client->dev, "%s: Skip cmd during pattern tracking workaround :%s\n",
  1757. __func__, buf);
  1758. return count;
  1759. }
  1760. #endif
  1761. if (data->cmd_is_running == true) {
  1762. dev_err(&rmi4_data->i2c_client->dev, "%s: Still servicing previous command. Skip cmd :%s\n",
  1763. __func__, buf);
  1764. return count;
  1765. }
  1766. if ((int)count >= CMD_STR_LEN) {
  1767. dev_info(&rmi4_data->i2c_client->dev, "%s: cmd size overflow![%d]\n",
  1768. __func__, (int)count);
  1769. return count;
  1770. }
  1771. mutex_lock(&data->cmd_lock);
  1772. data->cmd_is_running = true;
  1773. mutex_unlock(&data->cmd_lock);
  1774. data->cmd_state = CMD_STATUS_RUNNING;
  1775. length = (int)count;
  1776. if (*(buf + length - 1) == '\n')
  1777. length--;
  1778. memset(data->cmd, 0x00, sizeof(data->cmd));
  1779. memcpy(data->cmd, buf, length);
  1780. memset(data->cmd_param, 0, sizeof(data->cmd_param));
  1781. memset(buffer, 0x00, sizeof(buffer));
  1782. pos = strchr(buf, (int)delim);
  1783. if (pos)
  1784. memcpy(buffer, buf, pos - buf);
  1785. else
  1786. memcpy(buffer, buf, length);
  1787. /* find command */
  1788. list_for_each_entry(ft_cmd_ptr, &data->cmd_list_head, list) {
  1789. if (!strcmp(buffer, ft_cmd_ptr->cmd_name)) {
  1790. cmd_found = true;
  1791. break;
  1792. }
  1793. }
  1794. /* set not_support_cmd */
  1795. if (!cmd_found) {
  1796. list_for_each_entry(ft_cmd_ptr,
  1797. &data->cmd_list_head, list) {
  1798. if (!strcmp("not_support_cmd", ft_cmd_ptr->cmd_name))
  1799. break;
  1800. }
  1801. }
  1802. /* parsing parameters */
  1803. if (cmd_found && pos) {
  1804. pos++;
  1805. start = pos;
  1806. do {
  1807. if ((*pos == delim) || (pos - buf == length)) {
  1808. end = pos;
  1809. memset(buffer, 0x00, sizeof(buffer));
  1810. memcpy(buffer, start, end - start);
  1811. *(buffer + strlen(buffer)) = '\0';
  1812. param = data->cmd_param + param_cnt;
  1813. if (kstrtoint(buffer, 10, param) < 0)
  1814. break;
  1815. param_cnt++;
  1816. start = pos + 1;
  1817. }
  1818. pos++;
  1819. } while ((pos - buf <= length) && (param_cnt < CMD_PARAM_NUM));
  1820. }
  1821. dev_info(&rmi4_data->i2c_client->dev, "%s: Command = %s\n",
  1822. __func__, buf);
  1823. ft_cmd_ptr->cmd_func();
  1824. return count;
  1825. }
  1826. static ssize_t cmd_status_show(struct device *dev,
  1827. struct device_attribute *attr, char *buf)
  1828. {
  1829. char buffer[16];
  1830. struct factory_data *data = f54->factory_data;
  1831. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1832. dev_info(&rmi4_data->i2c_client->dev, "%s: Command status = %d\n",
  1833. __func__, data->cmd_state);
  1834. switch (data->cmd_state) {
  1835. case CMD_STATUS_WAITING:
  1836. sprintf(buffer, "%s", tostring(WAITING));
  1837. break;
  1838. case CMD_STATUS_RUNNING:
  1839. sprintf(buffer, "%s", tostring(RUNNING));
  1840. break;
  1841. case CMD_STATUS_OK:
  1842. sprintf(buffer, "%s", tostring(OK));
  1843. break;
  1844. case CMD_STATUS_FAIL:
  1845. sprintf(buffer, "%s", tostring(FAIL));
  1846. break;
  1847. case CMD_STATUS_NOT_APPLICABLE:
  1848. sprintf(buffer, "%s", tostring(NOT_APPLICABLE));
  1849. break;
  1850. default:
  1851. sprintf(buffer, "%s", tostring(NOT_APPLICABLE));
  1852. break;
  1853. }
  1854. return snprintf(buf, PAGE_SIZE, "%s\n", buffer);
  1855. }
  1856. static ssize_t cmd_result_show(struct device *dev,
  1857. struct device_attribute *attr, char *buf)
  1858. {
  1859. struct factory_data *data = f54->factory_data;
  1860. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  1861. dev_info(&rmi4_data->i2c_client->dev, "%s: Command result = %s\n",
  1862. __func__, data->cmd_result);
  1863. mutex_lock(&data->cmd_lock);
  1864. data->cmd_is_running = false;
  1865. mutex_unlock(&data->cmd_lock);
  1866. data->cmd_state = CMD_STATUS_WAITING;
  1867. return snprintf(buf, PAGE_SIZE, "%s\n", data->cmd_result);
  1868. }
  1869. static ssize_t cmd_list_show(struct device *dev,
  1870. struct device_attribute *attr, char *buf)
  1871. {
  1872. int ii = 0;
  1873. char buffer[CMD_RESULT_STR_LEN];
  1874. char buffer_name[CMD_STR_LEN];
  1875. snprintf(buffer, 30, "++factory command list++\n");
  1876. while (strncmp(ft_cmds[ii].cmd_name, "not_support_cmd", 16) != 0) {
  1877. snprintf(buffer_name, CMD_STR_LEN, "%s\n", ft_cmds[ii].cmd_name);
  1878. strncat(buffer, buffer_name, strlen(buffer_name));
  1879. ii++;
  1880. }
  1881. return snprintf(buf, PAGE_SIZE, "%s\n", buffer);
  1882. }
  1883. /* Caution : Below function run the force calibration for the mutual touch.
  1884. * So it should be used for the specific case.
  1885. */
  1886. int synaptics_rmi4_force_calibration(void)
  1887. {
  1888. int retval;
  1889. unsigned char command;
  1890. struct synaptics_rmi4_data *rmi4_data;
  1891. if (!f54)
  1892. return -ENOMEM;
  1893. if (f54->status == STATUS_BUSY)
  1894. return -EBUSY;
  1895. rmi4_data = f54->rmi4_data;
  1896. command = (unsigned char)COMMAND_FORCE_CAL;
  1897. retval = f54->fn_ptr->write(rmi4_data,
  1898. f54->command_base_addr,
  1899. &command,
  1900. sizeof(command));
  1901. dev_err(&rmi4_data->i2c_client->dev, "%s: Write force cal command %s\n",
  1902. __func__, (retval < 0) ? "Fail" : "Sucess");
  1903. return retval;
  1904. }
  1905. EXPORT_SYMBOL(synaptics_rmi4_force_calibration);
  1906. /* TODO: Below function is added to check that firmware update is needed or not.
  1907. * During development period, we need to support test firmware and various H/W
  1908. * type such as A1/B0.... So Below conditions are very compex, maybe we need to
  1909. * simplify this function not so far.
  1910. * Synaptics's test firmware binary doesn't have Ic and firmware version.
  1911. * in that case we skip update on booting time.
  1912. * otherwise we forced run the update during UMS update..
  1913. */
  1914. extern int system_rev;
  1915. static bool synaptics_skip_firmware_update(struct synaptics_rmi4_data *rmi4_data,
  1916. const struct firmware *fw_entry)
  1917. {
  1918. /* Read revision and firmware info from binary */
  1919. rmi4_data->ic_revision_of_bin = (int)fw_entry->data[IC_REVISION_BIN_OFFSET];
  1920. rmi4_data->fw_version_of_bin = (int)fw_entry->data[FW_VERSION_BIN_OFFSET];
  1921. dev_info(&rmi4_data->i2c_client->dev, "%s: [FW size. revision, version] [%d, 0x%02X/0x%02X(BIN/IC), 0x%02X/0x%02X(BIN/IC)]\n",
  1922. __func__, fw_entry->size,
  1923. rmi4_data->ic_revision_of_bin, rmi4_data->ic_revision_of_ic,
  1924. rmi4_data->fw_version_of_bin, rmi4_data->fw_version_of_ic);
  1925. dev_info(&rmi4_data->i2c_client->dev, "%s: [prog bit] [0x%02X]\n",
  1926. __func__, rmi4_data->flash_prog_mode);
  1927. if (system_rev < 6) {
  1928. /* If old HW has FW above B019 or BF17, then It's not a proper FW. do FW update */
  1929. if (((rmi4_data->ic_revision_of_ic == 0xB0) && (rmi4_data->fw_version_of_ic >= 0x19)) ||
  1930. ((rmi4_data->ic_revision_of_ic == 0xBF) && (rmi4_data->fw_version_of_ic >= 0x17))) {
  1931. dev_info(&rmi4_data->i2c_client->dev,
  1932. "%s: new hw's FW is in old hw\n",
  1933. __func__);
  1934. return false;
  1935. }
  1936. }
  1937. if (rmi4_data->flash_prog_mode) {
  1938. dev_err(&rmi4_data->i2c_client->dev, "%s: Force firmware update : Flash prog bit is setted fw\n",
  1939. __func__);
  1940. return false;
  1941. }
  1942. if ((rmi4_data->ic_revision_of_bin == rmi4_data->ic_revision_of_ic)
  1943. && (rmi4_data->fw_version_of_bin <= rmi4_data->fw_version_of_ic)
  1944. && (rmi4_data->fw_version_of_ic < rmi4_data->fw_version_of_bin + 0x10)) {
  1945. dev_info(&rmi4_data->i2c_client->dev, "%s: Do not need to update\n",
  1946. __func__);
  1947. return true;
  1948. }
  1949. return false;
  1950. }
  1951. int synaptics_rmi4_fw_update_on_probe(struct synaptics_rmi4_data *rmi4_data)
  1952. {
  1953. int retval;
  1954. const struct firmware *fw_entry = NULL;
  1955. unsigned char *fw_data = NULL;
  1956. char fw_path[SYNAPTICS_MAX_FW_PATH];
  1957. #ifdef CONFIG_SEC_FACTORY
  1958. snprintf(fw_path, SYNAPTICS_MAX_FW_PATH,
  1959. "%s", rmi4_data->fac_firmware_name);
  1960. #else
  1961. snprintf(fw_path, SYNAPTICS_MAX_FW_PATH,
  1962. "%s", rmi4_data->firmware_name);
  1963. #endif
  1964. dev_info(&rmi4_data->i2c_client->dev, "%s: Load firmware : %s\n",
  1965. __func__, fw_path);
  1966. retval = request_firmware(&fw_entry, fw_path, &rmi4_data->i2c_client->dev);
  1967. if (retval) {
  1968. dev_err(&rmi4_data->i2c_client->dev, "%s: Firmware image %s not available\n",
  1969. __func__, fw_path);
  1970. goto done;
  1971. }
  1972. if (synaptics_skip_firmware_update(rmi4_data, fw_entry))
  1973. goto done;
  1974. fw_data = (unsigned char *)fw_entry->data;
  1975. pr_info("%s: do fw update\n",__func__);
  1976. retval = synaptics_fw_updater(fw_data);
  1977. if (retval)
  1978. dev_err(&rmi4_data->i2c_client->dev, "%s: failed update firmware\n",
  1979. __func__);
  1980. done:
  1981. if (fw_entry)
  1982. release_firmware(fw_entry);
  1983. pr_info("synaptics %s:%d\n",__func__,__LINE__);
  1984. return retval;
  1985. }
  1986. EXPORT_SYMBOL(synaptics_rmi4_fw_update_on_probe);
  1987. static int synaptics_load_fw_from_kernel(struct synaptics_rmi4_data *rmi4_data, const char *fw_path)
  1988. {
  1989. int retval;
  1990. const struct firmware *fw_entry = NULL;
  1991. unsigned char *fw_data = NULL;
  1992. if (!fw_path) {
  1993. dev_err(&rmi4_data->i2c_client->dev, "%s: Firmware name is not defined\n",
  1994. __func__);
  1995. return -EINVAL;
  1996. }
  1997. dev_info(&rmi4_data->i2c_client->dev, "%s: Load firmware : %s\n",
  1998. __func__, fw_path);
  1999. retval = request_firmware(&fw_entry, fw_path,
  2000. &rmi4_data->i2c_client->dev);
  2001. if (retval) {
  2002. dev_err(&rmi4_data->i2c_client->dev, "%s: Firmware image %s not available\n",
  2003. __func__, fw_path);
  2004. goto done;
  2005. }
  2006. fw_data = (unsigned char *)fw_entry->data;
  2007. retval = synaptics_fw_updater(fw_data);
  2008. if (retval)
  2009. dev_err(&rmi4_data->i2c_client->dev, "%s: failed update firmware\n",
  2010. __func__);
  2011. done:
  2012. if (fw_entry)
  2013. release_firmware(fw_entry);
  2014. return retval;
  2015. }
  2016. static int synaptics_load_fw_from_ums(struct synaptics_rmi4_data *rmi4_data)
  2017. {
  2018. struct file *fp;
  2019. mm_segment_t old_fs;
  2020. unsigned short fw_size, nread;
  2021. int error = 0;
  2022. old_fs = get_fs();
  2023. set_fs(KERNEL_DS);
  2024. fp = filp_open(SYNAPTICS_DEFAULT_UMS_FW, O_RDONLY, S_IRUSR);
  2025. if (IS_ERR(fp)) {
  2026. dev_err(&rmi4_data->i2c_client->dev,
  2027. "%s: failed to open %s.\n", __func__, SYNAPTICS_DEFAULT_UMS_FW);
  2028. error = -ENOENT;
  2029. goto open_err;
  2030. }
  2031. fw_size = fp->f_path.dentry->d_inode->i_size;
  2032. if (0 < fw_size) {
  2033. unsigned char *fw_data;
  2034. fw_data = kzalloc(fw_size, GFP_KERNEL);
  2035. nread = vfs_read(fp, (char __user *)fw_data,
  2036. fw_size, &fp->f_pos);
  2037. dev_info(&rmi4_data->i2c_client->dev,
  2038. "%s: start, file path %s, size %u Bytes\n", __func__,
  2039. SYNAPTICS_DEFAULT_UMS_FW, fw_size);
  2040. if (nread != fw_size) {
  2041. dev_err(&rmi4_data->i2c_client->dev,
  2042. "%s: failed to read firmware file, nread %u Bytes\n",
  2043. __func__,
  2044. nread);
  2045. error = -EIO;
  2046. }
  2047. else
  2048. error = synaptics_fw_updater(fw_data);
  2049. if (error < 0)
  2050. dev_err(&rmi4_data->i2c_client->dev, "%s: failed update firmware\n",
  2051. __func__);
  2052. kfree(fw_data);
  2053. }
  2054. filp_close(fp, current->files);
  2055. open_err:
  2056. set_fs(old_fs);
  2057. return error;
  2058. }
  2059. static int synaptics_rmi4_fw_update_on_hidden_menu(struct synaptics_rmi4_data *rmi4_data,
  2060. int update_type)
  2061. {
  2062. int retval = 0;
  2063. /* Factory cmd for firmware update
  2064. * argument represent what is source of firmware like below.
  2065. *
  2066. * 0 : Getting firmware which is for user.
  2067. * 1 : Getting firmware from sd card.
  2068. * 2 : Getting firmware which is for factory test.
  2069. */
  2070. switch (update_type) {
  2071. case 0:
  2072. retval = synaptics_load_fw_from_kernel(rmi4_data, rmi4_data->firmware_name);
  2073. break;
  2074. case 1:
  2075. retval = synaptics_load_fw_from_ums(rmi4_data);
  2076. break;
  2077. case 2:
  2078. retval = synaptics_load_fw_from_kernel(rmi4_data, rmi4_data->fac_firmware_name);
  2079. break;
  2080. default:
  2081. dev_err(&rmi4_data->i2c_client->dev, "%s: Not support command[%d]\n",
  2082. __func__, update_type);
  2083. break;
  2084. }
  2085. return retval;
  2086. }
  2087. static void fw_update(void)
  2088. {
  2089. struct factory_data *data = f54->factory_data;
  2090. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2091. int retval = 0;
  2092. set_default_result(data);
  2093. retval = synaptics_rmi4_fw_update_on_hidden_menu(rmi4_data,
  2094. data->cmd_param[0]);
  2095. msleep(1000);
  2096. if (retval < 0) {
  2097. sprintf(data->cmd_buff, "%s", tostring(NA));
  2098. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2099. data->cmd_state = CMD_STATUS_FAIL;
  2100. dev_err(&rmi4_data->i2c_client->dev, "%s: failed [%d]\n",
  2101. __func__, retval);
  2102. } else {
  2103. sprintf(data->cmd_buff, "%s", tostring(OK));
  2104. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2105. data->cmd_state = CMD_STATUS_OK;
  2106. dev_info(&rmi4_data->i2c_client->dev, "%s: success [%d]\n",
  2107. __func__, retval);
  2108. }
  2109. return;
  2110. }
  2111. static void get_fw_ver_bin(void)
  2112. {
  2113. struct factory_data *data = f54->factory_data;
  2114. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2115. set_default_result(data);
  2116. sprintf(data->cmd_buff, "SY%04X%02X",
  2117. rmi4_data->ic_revision_of_bin,
  2118. rmi4_data->fw_version_of_bin);
  2119. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2120. data->cmd_state = CMD_STATUS_OK;
  2121. return;
  2122. }
  2123. static void get_fw_ver_ic(void)
  2124. {
  2125. struct factory_data *data = f54->factory_data;
  2126. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2127. set_default_result(data);
  2128. sprintf(data->cmd_buff, "SY%04X%02X",
  2129. rmi4_data->ic_revision_of_ic,
  2130. rmi4_data->fw_version_of_ic);
  2131. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2132. data->cmd_state = CMD_STATUS_OK;
  2133. return;
  2134. }
  2135. static void get_fac_fw_ver_bin(void)
  2136. {
  2137. struct factory_data *data = f54->factory_data;
  2138. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2139. int retval;
  2140. const struct firmware *fw_entry = NULL;
  2141. set_default_result(data);
  2142. retval = request_firmware(&fw_entry, rmi4_data->fac_firmware_name,
  2143. &rmi4_data->i2c_client->dev);
  2144. if (retval < 0) {
  2145. dev_err(&rmi4_data->i2c_client->dev,
  2146. "%s: factory firmware request failed\n",
  2147. __func__);
  2148. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2149. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2150. data->cmd_state = CMD_STATUS_FAIL;
  2151. } else {
  2152. sprintf(data->cmd_buff, "SY%02X%02X%02X",
  2153. (int)fw_entry->data[DATE_OF_FIRMWARE_BIN_OFFSET],
  2154. (int)fw_entry->data[IC_REVISION_BIN_OFFSET],
  2155. (int)fw_entry->data[FW_VERSION_BIN_OFFSET]);
  2156. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2157. data->cmd_state = CMD_STATUS_OK;
  2158. }
  2159. release_firmware(fw_entry);
  2160. return;
  2161. }
  2162. static void get_config_ver(void)
  2163. {
  2164. struct factory_data *data = f54->factory_data;
  2165. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2166. set_default_result(data);
  2167. sprintf(data->cmd_buff, "%s_SY_%02d%02d",
  2168. SYNAPTICS_DEVICE_NAME, rmi4_data->fw_release_date_of_ic >> 8,
  2169. rmi4_data->fw_release_date_of_ic & 0x00FF);
  2170. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2171. data->cmd_state = CMD_STATUS_OK;
  2172. return;
  2173. }
  2174. static void get_threshold(void)
  2175. {
  2176. unsigned char SaturationCap_LSB;
  2177. unsigned char SaturationCap_MSB;
  2178. unsigned char FingerAmplitudeThreshold;
  2179. unsigned int SaturationCap;
  2180. unsigned int threshold_integer;
  2181. unsigned int threshold_fraction;
  2182. struct factory_data *data = f54->factory_data;
  2183. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2184. f54->fn_ptr->read(rmi4_data,
  2185. F12_CTRL15_ADDR,
  2186. &FingerAmplitudeThreshold,
  2187. sizeof(FingerAmplitudeThreshold));
  2188. f54->fn_ptr->read(rmi4_data,
  2189. f54->control.reg_2->address,
  2190. &SaturationCap_LSB,
  2191. sizeof(SaturationCap_LSB));
  2192. f54->fn_ptr->read(rmi4_data,
  2193. f54->control.reg_2->address + 1,
  2194. &SaturationCap_MSB,
  2195. sizeof(SaturationCap_MSB));
  2196. SaturationCap = (SaturationCap_LSB & 0xFF) | ((SaturationCap_MSB & 0xFF) <<8);
  2197. threshold_integer = (FingerAmplitudeThreshold * SaturationCap)/256;
  2198. threshold_fraction = ((FingerAmplitudeThreshold * SaturationCap * 1000)/256)%1000;
  2199. dev_info(&rmi4_data->i2c_client->dev,
  2200. "%s: FingerAmp : %d, Satruration cap : %d\n",
  2201. __func__, FingerAmplitudeThreshold, SaturationCap);
  2202. set_default_result(data);
  2203. sprintf(data->cmd_buff, "%u.%u",
  2204. threshold_integer, threshold_fraction);
  2205. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2206. data->cmd_state = CMD_STATUS_OK;
  2207. return;
  2208. }
  2209. static void module_off_master(void)
  2210. {
  2211. struct factory_data *data = f54->factory_data;
  2212. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2213. set_default_result(data);
  2214. mutex_lock(&rmi4_data->input_dev->mutex);
  2215. rmi4_data->stop_device(rmi4_data);
  2216. mutex_unlock(&rmi4_data->input_dev->mutex);
  2217. sprintf(data->cmd_buff, "%s", tostring(OK));
  2218. data->cmd_state = CMD_STATUS_OK;
  2219. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2220. }
  2221. static void module_on_master(void)
  2222. {
  2223. struct factory_data *data = f54->factory_data;
  2224. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2225. int retval;
  2226. set_default_result(data);
  2227. mutex_lock(&rmi4_data->input_dev->mutex);
  2228. retval = rmi4_data->start_device(rmi4_data);
  2229. if (retval < 0)
  2230. dev_err(&rmi4_data->i2c_client->dev,
  2231. "%s: Failed to start device\n", __func__);
  2232. mutex_unlock(&rmi4_data->input_dev->mutex);
  2233. sprintf(data->cmd_buff, "%s", tostring(OK));
  2234. data->cmd_state = CMD_STATUS_OK;
  2235. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2236. }
  2237. static void get_chip_vendor(void)
  2238. {
  2239. struct factory_data *data = f54->factory_data;
  2240. set_default_result(data);
  2241. sprintf(data->cmd_buff, "%s", tostring(SYNAPTICS));
  2242. data->cmd_state = CMD_STATUS_OK;
  2243. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2244. }
  2245. static void get_chip_name(void)
  2246. {
  2247. struct factory_data *data = f54->factory_data;
  2248. set_default_result(data);
  2249. sprintf(data->cmd_buff, "%s", tostring(S5000));
  2250. data->cmd_state = CMD_STATUS_OK;
  2251. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2252. }
  2253. static void get_x_num(void)
  2254. {
  2255. struct factory_data *data = f54->factory_data;
  2256. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2257. set_default_result(data);
  2258. sprintf(data->cmd_buff, "%d", rmi4_data->num_of_tx);
  2259. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2260. data->cmd_state = CMD_STATUS_OK;
  2261. return;
  2262. }
  2263. static void get_y_num(void)
  2264. {
  2265. struct factory_data *data = f54->factory_data;
  2266. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2267. set_default_result(data);
  2268. sprintf(data->cmd_buff, "%d", rmi4_data->num_of_rx);
  2269. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2270. data->cmd_state = CMD_STATUS_OK;
  2271. return;
  2272. }
  2273. static int check_rx_tx_num(void)
  2274. {
  2275. struct factory_data *data = f54->factory_data;
  2276. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2277. int node;
  2278. dev_info(&rmi4_data->i2c_client->dev, "%s: param[0] = %d, param[1] = %d\n",
  2279. __func__, data->cmd_param[0], data->cmd_param[1]);
  2280. if (data->cmd_param[0] < 0 ||
  2281. data->cmd_param[0] >= rmi4_data->num_of_tx ||
  2282. data->cmd_param[1] < 0 ||
  2283. data->cmd_param[1] >= rmi4_data->num_of_rx) {
  2284. sprintf(data->cmd_buff, "%s", tostring(NA));
  2285. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2286. data->cmd_state = CMD_STATUS_FAIL;
  2287. dev_info(&rmi4_data->i2c_client->dev, "%s: parameter error: %u,%u\n",
  2288. __func__, data->cmd_param[0], data->cmd_param[1]);
  2289. node = -1;
  2290. } else {
  2291. node = data->cmd_param[0] * rmi4_data->num_of_tx +
  2292. data->cmd_param[1];
  2293. dev_info(&rmi4_data->i2c_client->dev, "%s: node = %d\n",
  2294. __func__, node);
  2295. }
  2296. return node;
  2297. }
  2298. static void get_rawcap(void)
  2299. {
  2300. int node;
  2301. short report_data;
  2302. struct factory_data *data = f54->factory_data;
  2303. set_default_result(data);
  2304. node = check_rx_tx_num();
  2305. if (node < 0) {
  2306. data->cmd_state = CMD_STATUS_FAIL;
  2307. return;
  2308. } else {
  2309. report_data = f54->factory_data->rawcap_data[node];
  2310. sprintf(data->cmd_buff, "%d", report_data);
  2311. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2312. data->cmd_state = CMD_STATUS_OK;
  2313. }
  2314. return;
  2315. }
  2316. static void run_rawcap_read(void)
  2317. {
  2318. int retval;
  2319. int kk = 0;
  2320. unsigned char ii;
  2321. unsigned char jj;
  2322. unsigned char num_of_tx;
  2323. unsigned char num_of_rx;
  2324. short *report_data;
  2325. short max_value;
  2326. short min_value;
  2327. short cur_value;
  2328. struct factory_data *data = f54->factory_data;
  2329. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2330. unsigned char command = 0x01;
  2331. set_default_result(data);
  2332. if (f54->rmi4_data->ic_revision_of_ic != 0xBF) {
  2333. dev_info(&f54->rmi4_data->i2c_client->dev,
  2334. "%s: this is not Factory FW.\n", __func__);
  2335. sprintf(data->cmd_buff, "%s", "Not Factory Firmware");
  2336. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2337. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2338. return;
  2339. }
  2340. if (rmi4_data->touch_stopped) {
  2341. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  2342. __func__);
  2343. sprintf(data->cmd_buff, "%s", "TSP turned off");
  2344. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2345. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2346. return;
  2347. }
  2348. retval = do_preparation();
  2349. if (retval < 0) {
  2350. dev_err(&rmi4_data->i2c_client->dev,
  2351. "%s: Failed to do preparation\n",
  2352. __func__);
  2353. sprintf(data->cmd_buff, "%s", "Error preparation");
  2354. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2355. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2356. return;
  2357. }
  2358. if (!synaptics_rmi4_f54_get_report_type(CMD_REPORT_TYPE_RAWCAP)) {
  2359. data->cmd_state = CMD_STATUS_FAIL;
  2360. goto exit;
  2361. }
  2362. report_data = f54->factory_data->rawcap_data;
  2363. memcpy(report_data, f54->report_data, f54->report_size);
  2364. num_of_tx = rmi4_data->num_of_tx;
  2365. num_of_rx = rmi4_data->num_of_rx;
  2366. max_value = min_value = report_data[0];
  2367. for (ii = 0; ii < num_of_tx; ii++) {
  2368. for (jj = 0; jj < num_of_rx; jj++) {
  2369. cur_value = *report_data;
  2370. max_value = max(max_value, cur_value);
  2371. min_value = min(min_value, cur_value);
  2372. report_data++;
  2373. if (cur_value > TSP_RAWCAP_MAX || cur_value < TSP_RAWCAP_MIN)
  2374. dev_info(&rmi4_data->i2c_client->dev,
  2375. "tx = %02d, rx = %02d, data[%d] = %d\n",
  2376. ii, jj, kk, cur_value);
  2377. kk++;
  2378. }
  2379. }
  2380. sprintf(data->cmd_buff, "%d,%d", min_value, max_value);
  2381. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2382. data->cmd_state = CMD_STATUS_OK;
  2383. exit:
  2384. /* soft reset */
  2385. retval = f54->fn_ptr->write(rmi4_data,
  2386. rmi4_data->f01_cmd_base_addr,
  2387. &command,
  2388. sizeof(command));
  2389. if (retval < 0) {
  2390. dev_err(&rmi4_data->i2c_client->dev,
  2391. "%s: Failed to issue reset command, error = %d\n",
  2392. __func__, retval);
  2393. }
  2394. return;
  2395. }
  2396. static void get_delta(void)
  2397. {
  2398. int node;
  2399. short report_data;
  2400. struct factory_data *data = f54->factory_data;
  2401. set_default_result(data);
  2402. node = check_rx_tx_num();
  2403. if (node < 0) {
  2404. data->cmd_state = CMD_STATUS_FAIL;
  2405. return;
  2406. } else {
  2407. report_data = f54->factory_data->delta_data[node];
  2408. sprintf(data->cmd_buff, "%d", report_data);
  2409. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2410. data->cmd_state = CMD_STATUS_OK;
  2411. }
  2412. }
  2413. static void run_delta_read(void)
  2414. {
  2415. struct factory_data *data = f54->factory_data;
  2416. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2417. short *report_data;
  2418. short cur_value;
  2419. unsigned char ii;
  2420. unsigned char jj;
  2421. unsigned char num_of_tx;
  2422. unsigned char num_of_rx;
  2423. int kk = 0;
  2424. set_default_result(data);
  2425. if (f54->rmi4_data->ic_revision_of_ic != 0xBF) {
  2426. dev_info(&f54->rmi4_data->i2c_client->dev,
  2427. "%s: this is not Factory FW.\n", __func__);
  2428. sprintf(data->cmd_buff, "%s", "Not Factory Firmware");
  2429. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2430. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2431. return;
  2432. }
  2433. if (rmi4_data->touch_stopped) {
  2434. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  2435. __func__);
  2436. sprintf(data->cmd_buff, "%s", "TSP turned off");
  2437. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2438. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2439. return;
  2440. }
  2441. if (!synaptics_rmi4_f54_get_report_type(CMD_REPORT_TYPE_DELTA)) {
  2442. data->cmd_state = CMD_STATUS_FAIL;
  2443. return;
  2444. }
  2445. report_data = f54->factory_data->delta_data;
  2446. memcpy(report_data, f54->report_data, f54->report_size);
  2447. num_of_tx = rmi4_data->num_of_tx;
  2448. num_of_rx = rmi4_data->num_of_rx;
  2449. for (ii = 0; ii < num_of_tx; ii++) {
  2450. for (jj = 0; jj < num_of_rx; jj++) {
  2451. cur_value = *report_data;
  2452. report_data++;
  2453. if (cur_value > TSP_DELTA_MAX || cur_value < TSP_DELTA_MIN)
  2454. dev_info(&rmi4_data->i2c_client->dev,
  2455. "tx = %02d, rx = %02d, data[%d] = %d\n",
  2456. ii, jj, kk, cur_value);
  2457. kk++;
  2458. }
  2459. }
  2460. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2461. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2462. data->cmd_state = CMD_STATUS_OK;
  2463. return;
  2464. }
  2465. static void run_abscap_read(void)
  2466. {
  2467. struct factory_data *data = f54->factory_data;
  2468. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2469. unsigned short *report_data;
  2470. char temp[CMD_STR_LEN];
  2471. char temp2[CMD_RESULT_STR_LEN];
  2472. unsigned char ii;
  2473. unsigned short num_of_tx;
  2474. unsigned short num_of_rx;
  2475. set_default_result(data);
  2476. if (f54->rmi4_data->ic_revision_of_ic != 0xBF) {
  2477. dev_info(&f54->rmi4_data->i2c_client->dev,
  2478. "%s: this is not Factory FW.\n", __func__);
  2479. sprintf(data->cmd_buff, "%s", "Not Factory Firmware");
  2480. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2481. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2482. return;
  2483. }
  2484. if (rmi4_data->touch_stopped) {
  2485. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  2486. __func__);
  2487. sprintf(data->cmd_buff, "%s", "TSP turned off");
  2488. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2489. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2490. return;
  2491. }
  2492. if (!synaptics_rmi4_f54_get_report_type(F54_ABS_RAW_CAP)) {
  2493. data->cmd_state = CMD_STATUS_FAIL;
  2494. return;
  2495. }
  2496. report_data = f54->factory_data->abscap_data;
  2497. memcpy(report_data, f54->report_data, f54->report_size);
  2498. memset(temp, 0, CMD_STR_LEN);
  2499. memset(temp2, 0, CMD_RESULT_STR_LEN);
  2500. num_of_tx = rmi4_data->num_of_tx;
  2501. num_of_rx = rmi4_data->num_of_rx;
  2502. for (ii = 0; ii < num_of_rx + num_of_tx; ii++) {
  2503. *report_data &= 0x0FFFF;
  2504. dev_info(&rmi4_data->i2c_client->dev,
  2505. "%s: %s [%d] = %d\n", __func__,
  2506. ii >= num_of_rx ? "Tx" : "Rx",
  2507. ii < num_of_rx ? ii : ii - num_of_rx,
  2508. *report_data);
  2509. sprintf(temp, "%d,", *report_data);
  2510. strncat(temp2, temp, 9);
  2511. report_data += 2;
  2512. }
  2513. sprintf(data->cmd_buff, "%s", temp2);
  2514. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2515. data->cmd_state = CMD_STATUS_OK;
  2516. return;
  2517. }
  2518. static void run_absdelta_read(void)
  2519. {
  2520. struct factory_data *data = f54->factory_data;
  2521. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2522. short *report_data;
  2523. char temp[CMD_STR_LEN];
  2524. char temp2[CMD_RESULT_STR_LEN];
  2525. unsigned char ii;
  2526. unsigned short num_of_tx;
  2527. unsigned short num_of_rx;
  2528. set_default_result(data);
  2529. if (f54->rmi4_data->ic_revision_of_ic != 0xBF) {
  2530. dev_info(&f54->rmi4_data->i2c_client->dev,
  2531. "%s: this is not Factory FW.\n", __func__);
  2532. sprintf(data->cmd_buff, "%s", "Not Factory Firmware");
  2533. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2534. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2535. return;
  2536. }
  2537. if (rmi4_data->touch_stopped) {
  2538. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  2539. __func__);
  2540. sprintf(data->cmd_buff, "%s", "TSP turned off");
  2541. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2542. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2543. return;
  2544. }
  2545. if (!synaptics_rmi4_f54_get_report_type(F54_ABS_DELTA_CAP)) {
  2546. data->cmd_state = CMD_STATUS_FAIL;
  2547. return;
  2548. }
  2549. report_data = f54->factory_data->absdelta_data;
  2550. memcpy(report_data, f54->report_data, f54->report_size);
  2551. memset(temp, 0, CMD_STR_LEN);
  2552. memset(temp2, 0, CMD_RESULT_STR_LEN);
  2553. num_of_tx = rmi4_data->num_of_tx;
  2554. num_of_rx = rmi4_data->num_of_rx;
  2555. for (ii = 0; ii < num_of_rx + num_of_tx; ii++) {
  2556. dev_info(&rmi4_data->i2c_client->dev,
  2557. "%s: %s [%d] = %d\n", __func__,
  2558. ii >= num_of_rx ? "Tx" : "Rx",
  2559. ii < num_of_rx ? ii : ii - num_of_rx,
  2560. *report_data);
  2561. sprintf(temp, "%d,", *report_data);
  2562. strncat(temp2, temp, 5);
  2563. report_data += 2;
  2564. }
  2565. sprintf(data->cmd_buff, "%s", temp2);
  2566. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2567. data->cmd_state = CMD_STATUS_OK;
  2568. return;
  2569. }
  2570. static void run_trx_short_test(void)
  2571. {
  2572. struct factory_data *data = f54->factory_data;
  2573. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2574. short *report_data;
  2575. unsigned char ii;
  2576. int retval = 0;
  2577. unsigned char command = 0x01;
  2578. set_default_result(data);
  2579. if (f54->rmi4_data->ic_revision_of_ic != 0xBF) {
  2580. dev_info(&f54->rmi4_data->i2c_client->dev,
  2581. "%s: this is not Factory FW.\n", __func__);
  2582. sprintf(data->cmd_buff, "%s", "Not Factory Firmware");
  2583. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2584. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2585. return;
  2586. }
  2587. if (rmi4_data->touch_stopped) {
  2588. dev_err(&rmi4_data->i2c_client->dev, "%s: [ERROR] Touch is stopped\n",
  2589. __func__);
  2590. sprintf(data->cmd_buff, "%s", "TSP turned off");
  2591. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2592. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2593. return;
  2594. }
  2595. disable_irq(rmi4_data->i2c_client->irq);
  2596. if (!synaptics_rmi4_f54_get_report_type(F54_TREX_SHORTS)) {
  2597. data->cmd_state = CMD_STATUS_FAIL;
  2598. goto exit;
  2599. }
  2600. report_data = f54->factory_data->trx_short;
  2601. memcpy(report_data, f54->report_data, f54->report_size);
  2602. for (ii = 0; ii < f54->report_size; ii++) {
  2603. dev_info(&rmi4_data->i2c_client->dev,
  2604. "%s: [%d]: [%x][%x][%x][%x][%x][%x][%x][%x]\n",
  2605. __func__, ii, *report_data & 0x1, (*report_data & 0x2) >> 1,
  2606. (*report_data & 0x4) >> 2, (*report_data & 0x8) >> 3,
  2607. (*report_data & 0x10) >> 4, (*report_data & 0x20) >> 5,
  2608. (*report_data & 0x40) >> 6, (*report_data & 0x80) >> 7);
  2609. if (*report_data > 0)
  2610. retval++;
  2611. report_data++;
  2612. }
  2613. if (retval > 0)
  2614. sprintf(data->cmd_buff, "FAIL");
  2615. else
  2616. sprintf(data->cmd_buff, "OK");
  2617. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2618. data->cmd_state = CMD_STATUS_OK;
  2619. exit:
  2620. enable_irq(rmi4_data->i2c_client->irq);
  2621. /* soft reset */
  2622. retval = f54->fn_ptr->write(rmi4_data,
  2623. rmi4_data->f01_cmd_base_addr,
  2624. &command,
  2625. sizeof(command));
  2626. if (retval < 0) {
  2627. dev_err(&rmi4_data->i2c_client->dev,
  2628. "%s: Failed to issue reset command, error = %d\n",
  2629. __func__, retval);
  2630. }
  2631. return;
  2632. }
  2633. static void hover_enable(void)
  2634. {
  2635. struct factory_data *data = f54->factory_data;
  2636. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2637. set_default_result(data);
  2638. if (data->cmd_param[0] < 0 || data->cmd_param[0] > 1) {
  2639. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2640. data->cmd_state = CMD_STATUS_FAIL;
  2641. } else {
  2642. int retval, enables;
  2643. enables = data->cmd_param[0];
  2644. rmi4_data->hover_status_in_normal_mode = data->cmd_param[0];
  2645. rmi4_data->hover_called = true;
  2646. rmi4_data->hover_ic = rmi4_data->flip_status;
  2647. retval = synaptics_rmi4_proximity_enables(enables);
  2648. if (retval < 0) {
  2649. dev_err(&rmi4_data->i2c_client->dev,
  2650. "%s failed, retval = %d\n",
  2651. __func__, retval);
  2652. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2653. data->cmd_state = CMD_STATUS_FAIL;
  2654. } else {
  2655. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2656. data->cmd_state = CMD_STATUS_OK;
  2657. }
  2658. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2659. data->cmd_state = CMD_STATUS_OK;
  2660. }
  2661. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2662. mutex_lock(&data->cmd_lock);
  2663. data->cmd_is_running = false;
  2664. mutex_unlock(&data->cmd_lock);
  2665. data->cmd_state = CMD_STATUS_WAITING;
  2666. return;
  2667. }
  2668. static void hover_no_sleep_enable(void)
  2669. {
  2670. struct factory_data *data = f54->factory_data;
  2671. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2672. set_default_result(data);
  2673. if (data->cmd_param[0] < 0 || data->cmd_param[0] > 1) {
  2674. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2675. data->cmd_state = CMD_STATUS_FAIL;
  2676. } else {
  2677. int retval;
  2678. if (data->cmd_param[0])
  2679. retval = synaptics_proximity_no_sleep_set(true);
  2680. else
  2681. retval = synaptics_proximity_no_sleep_set(false);
  2682. if (retval < 0) {
  2683. dev_err(&rmi4_data->i2c_client->dev, "%s failed, retval = %d\n",
  2684. __func__, retval);
  2685. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2686. data->cmd_state = CMD_STATUS_FAIL;
  2687. } else {
  2688. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2689. data->cmd_state = CMD_STATUS_OK;
  2690. }
  2691. }
  2692. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2693. return;
  2694. }
  2695. #ifdef CONFIG_GLOVE_TOUCH
  2696. #define GLOVE_MODE_EN (1 << 0)
  2697. #define CLEAR_COVER_EN (1 << 1)
  2698. #define FAST_GLOVE_MODE_EN (1 << 2)
  2699. static void glove_mode(void)
  2700. {
  2701. struct factory_data *data = f54->factory_data;
  2702. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2703. set_default_result(data);
  2704. if (rmi4_data->glove_mode_enables & CLEAR_COVER_EN) {
  2705. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2706. data->cmd_state = CMD_STATUS_OK;
  2707. dev_info(&rmi4_data->i2c_client->dev,
  2708. "%s Skip glove mode set (cover bit enabled)\n",
  2709. __func__);
  2710. goto skip_glove_mode_set;
  2711. }
  2712. if (data->cmd_param[0] < 0 || data->cmd_param[0] > 1) {
  2713. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2714. data->cmd_state = CMD_STATUS_FAIL;
  2715. } else {
  2716. int retval;
  2717. if (data->cmd_param[0])
  2718. rmi4_data->glove_mode_enables |= GLOVE_MODE_EN;
  2719. else
  2720. rmi4_data->glove_mode_enables &= ~(GLOVE_MODE_EN);
  2721. retval = synaptics_rmi4_glove_mode_enables(rmi4_data);
  2722. if (retval < 0) {
  2723. dev_err(&rmi4_data->i2c_client->dev,
  2724. "%s failed, retval = %d\n",
  2725. __func__, retval);
  2726. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2727. data->cmd_state = CMD_STATUS_FAIL;
  2728. } else {
  2729. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2730. data->cmd_state = CMD_STATUS_OK;
  2731. }
  2732. }
  2733. skip_glove_mode_set:
  2734. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2735. mutex_lock(&data->cmd_lock);
  2736. data->cmd_is_running = false;
  2737. mutex_unlock(&data->cmd_lock);
  2738. data->cmd_state = CMD_STATUS_WAITING;
  2739. return;
  2740. }
  2741. static void fast_glove_mode(void)
  2742. {
  2743. struct factory_data *data = f54->factory_data;
  2744. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2745. set_default_result(data);
  2746. if (data->cmd_param[0] < 0 || data->cmd_param[0] > 1) {
  2747. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2748. data->cmd_state = CMD_STATUS_FAIL;
  2749. } else {
  2750. int retval;
  2751. if (data->cmd_param[0]) {
  2752. rmi4_data->glove_mode_enables |= FAST_GLOVE_MODE_EN | GLOVE_MODE_EN;
  2753. rmi4_data->fast_glove_state = true;
  2754. }
  2755. else {
  2756. rmi4_data->glove_mode_enables &= ~(FAST_GLOVE_MODE_EN);
  2757. rmi4_data->fast_glove_state = false;
  2758. }
  2759. retval = synaptics_rmi4_glove_mode_enables(rmi4_data);
  2760. if (retval < 0) {
  2761. dev_err(&rmi4_data->i2c_client->dev,
  2762. "%s failed, retval = %d\n",
  2763. __func__, retval);
  2764. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2765. data->cmd_state = CMD_STATUS_FAIL;
  2766. } else {
  2767. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2768. data->cmd_state = CMD_STATUS_OK;
  2769. }
  2770. }
  2771. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2772. mutex_lock(&data->cmd_lock);
  2773. data->cmd_is_running = false;
  2774. mutex_unlock(&data->cmd_lock);
  2775. data->cmd_state = CMD_STATUS_WAITING;
  2776. return;
  2777. }
  2778. static void clear_cover_mode(void)
  2779. {
  2780. struct factory_data *data = f54->factory_data;
  2781. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2782. set_default_result(data);
  2783. if (data->cmd_param[0] < 0 || data->cmd_param[0] > 3) {
  2784. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2785. data->cmd_state = CMD_STATUS_FAIL;
  2786. } else {
  2787. int retval;
  2788. rmi4_data->glove_mode_enables = data->cmd_param[0];
  2789. if (data->cmd_param[0] && rmi4_data->fast_glove_state)
  2790. rmi4_data->glove_mode_enables |= FAST_GLOVE_MODE_EN;
  2791. retval = synaptics_rmi4_glove_mode_enables(rmi4_data);
  2792. if (retval < 0) {
  2793. dev_err(&rmi4_data->i2c_client->dev,
  2794. "%s failed, retval = %d\n",
  2795. __func__, retval);
  2796. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2797. data->cmd_state = CMD_STATUS_FAIL;
  2798. } else {
  2799. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2800. data->cmd_state = CMD_STATUS_OK;
  2801. }
  2802. /* Sync user setting value when wakeup with flip cover opened */
  2803. if ((0x02 == rmi4_data->glove_mode_enables) ||
  2804. (0x06 == rmi4_data->glove_mode_enables)) {
  2805. rmi4_data->glove_mode_enables &= ~(CLEAR_COVER_EN);
  2806. if (rmi4_data->fast_glove_state)
  2807. rmi4_data->glove_mode_enables |= GLOVE_MODE_EN;
  2808. }
  2809. }
  2810. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2811. mutex_lock(&data->cmd_lock);
  2812. data->cmd_is_running = false;
  2813. mutex_unlock(&data->cmd_lock);
  2814. data->cmd_state = CMD_STATUS_WAITING;
  2815. return;
  2816. }
  2817. static void get_glove_sensitivity(void)
  2818. {
  2819. struct factory_data *data = f54->factory_data;
  2820. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2821. set_default_result(data);
  2822. dev_info(&rmi4_data->i2c_client->dev,
  2823. "%s : %x\n", __func__, rmi4_data->gloved_sensitivity & 0x0F);
  2824. sprintf(data->cmd_buff, "%x", rmi4_data->gloved_sensitivity & 0x0F);
  2825. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2826. data->cmd_state = CMD_STATUS_OK;
  2827. return;
  2828. }
  2829. #endif
  2830. #ifdef TSP_BOOSTER
  2831. static void boost_level(void)
  2832. {
  2833. struct factory_data *data = f54->factory_data;
  2834. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2835. int retval;
  2836. dev_info(&rmi4_data->i2c_client->dev, "%s\n", __func__);
  2837. set_default_result(data);
  2838. rmi4_data->dvfs_boost_mode = data->cmd_param[0];
  2839. dev_info(&rmi4_data->i2c_client->dev,
  2840. "%s: dvfs_boost_mode = %d\n",
  2841. __func__, rmi4_data->dvfs_boost_mode);
  2842. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2843. data->cmd_state = CMD_STATUS_OK;
  2844. if (rmi4_data->dvfs_boost_mode == DVFS_STAGE_NONE) {
  2845. retval = set_freq_limit(DVFS_TOUCH_ID, -1);
  2846. if (retval < 0) {
  2847. dev_err(&rmi4_data->i2c_client->dev,
  2848. "%s: booster stop failed(%d).\n",
  2849. __func__, retval);
  2850. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2851. data->cmd_state = CMD_STATUS_FAIL;
  2852. rmi4_data->dvfs_lock_status = false;
  2853. }
  2854. }
  2855. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2856. mutex_lock(&data->cmd_lock);
  2857. data->cmd_is_running = false;
  2858. mutex_unlock(&data->cmd_lock);
  2859. data->cmd_state = CMD_STATUS_WAITING;
  2860. return;
  2861. }
  2862. #endif
  2863. static void switch_sel(void)
  2864. {
  2865. struct factory_data *data = f54->factory_data;
  2866. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2867. int sel_status;
  2868. set_default_result(data);
  2869. sel_status = data->cmd_param[0];
  2870. dev_info(&rmi4_data->i2c_client->dev, "%s : %d\n", __func__, sel_status);
  2871. sprintf(data->cmd_buff, "switch to %s", sel_status ? "TSP_SUB" : "TSP_MAIN");
  2872. if(rmi4_data->tsp_probe && (sel_status == TSP_MAIN || sel_status == TSP_SUB)){
  2873. gpio_set_value(rmi4_data->dt_data->tsp_sel, sel_status);
  2874. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "OK");
  2875. data->cmd_state = CMD_STATUS_OK;
  2876. } else {
  2877. snprintf(data->cmd_buff, sizeof(data->cmd_buff), "NG");
  2878. data->cmd_state = CMD_STATUS_FAIL;
  2879. }
  2880. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2881. mutex_lock(&data->cmd_lock);
  2882. data->cmd_is_running = false;
  2883. mutex_unlock(&data->cmd_lock);
  2884. return;
  2885. }
  2886. static void not_support_cmd(void)
  2887. {
  2888. struct factory_data *data = f54->factory_data;
  2889. set_default_result(data);
  2890. sprintf(data->cmd_buff, "%s", tostring(NA));
  2891. set_cmd_result(data, data->cmd_buff, strlen(data->cmd_buff));
  2892. data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
  2893. }
  2894. #endif
  2895. static ssize_t synaptics_rmi4_f54_status_show(struct device *dev,
  2896. struct device_attribute *attr, char *buf)
  2897. {
  2898. return snprintf(buf, PAGE_SIZE, "%u\n", f54->status);
  2899. }
  2900. static ssize_t synaptics_rmi4_f54_report_size_show(struct device *dev,
  2901. struct device_attribute *attr, char *buf)
  2902. {
  2903. return snprintf(buf, PAGE_SIZE, "%u\n", f54->report_size);
  2904. }
  2905. static ssize_t synaptics_rmi4_f54_no_auto_cal_show(struct device *dev,
  2906. struct device_attribute *attr, char *buf)
  2907. {
  2908. return snprintf(buf, PAGE_SIZE, "%u\n", f54->no_auto_cal);
  2909. }
  2910. static ssize_t synaptics_rmi4_f54_no_auto_cal_store(struct device *dev,
  2911. struct device_attribute *attr, const char *buf, size_t count)
  2912. {
  2913. int retval;
  2914. unsigned char data;
  2915. unsigned long setting;
  2916. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2917. retval = kstrtoul(buf, 10, &setting);
  2918. if (retval)
  2919. return retval;
  2920. if (setting > 1)
  2921. return -EINVAL;
  2922. retval = f54->fn_ptr->read(rmi4_data,
  2923. f54->control_base_addr,
  2924. &data,
  2925. sizeof(data));
  2926. if (retval < 0) {
  2927. dev_err(&rmi4_data->i2c_client->dev,
  2928. "%s: Failed to read control register\n",
  2929. __func__);
  2930. return retval;
  2931. }
  2932. if ((data & NO_AUTO_CAL_MASK) == setting)
  2933. return count;
  2934. data = (data & ~NO_AUTO_CAL_MASK) | (data & NO_AUTO_CAL_MASK);
  2935. retval = f54->fn_ptr->write(rmi4_data,
  2936. f54->control_base_addr,
  2937. &data,
  2938. sizeof(data));
  2939. if (retval < 0) {
  2940. dev_err(&rmi4_data->i2c_client->dev,
  2941. "%s: Failed to write control register\n",
  2942. __func__);
  2943. return retval;
  2944. }
  2945. f54->no_auto_cal = (setting == 1);
  2946. return count;
  2947. }
  2948. static ssize_t synaptics_rmi4_f54_report_type_show(struct device *dev,
  2949. struct device_attribute *attr, char *buf)
  2950. {
  2951. return snprintf(buf, PAGE_SIZE, "%u\n", f54->report_type);
  2952. }
  2953. static ssize_t synaptics_rmi4_f54_report_type_store(struct device *dev,
  2954. struct device_attribute *attr, const char *buf, size_t count)
  2955. {
  2956. int retval;
  2957. unsigned char data;
  2958. unsigned long setting;
  2959. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2960. retval = kstrtoul(buf, 10, &setting);
  2961. if (retval)
  2962. return retval;
  2963. if (!is_report_type_valid((enum f54_report_types)setting)) {
  2964. dev_err(&rmi4_data->i2c_client->dev,
  2965. "%s: Report type not supported by driver\n",
  2966. __func__);
  2967. return -EINVAL;
  2968. }
  2969. mutex_lock(&f54->status_mutex);
  2970. if (f54->status != STATUS_BUSY) {
  2971. f54->report_type = (enum f54_report_types)setting;
  2972. data = (unsigned char)setting;
  2973. retval = f54->fn_ptr->write(rmi4_data,
  2974. f54->data_base_addr,
  2975. &data,
  2976. sizeof(data));
  2977. mutex_unlock(&f54->status_mutex);
  2978. if (retval < 0) {
  2979. dev_err(&rmi4_data->i2c_client->dev,
  2980. "%s: Failed to write data register\n",
  2981. __func__);
  2982. return retval;
  2983. }
  2984. return count;
  2985. } else {
  2986. dev_err(&rmi4_data->i2c_client->dev,
  2987. "%s: Previous get report still ongoing\n",
  2988. __func__);
  2989. mutex_unlock(&f54->status_mutex);
  2990. return -EINVAL;
  2991. }
  2992. }
  2993. static ssize_t synaptics_rmi4_f54_fifoindex_show(struct device *dev,
  2994. struct device_attribute *attr, char *buf)
  2995. {
  2996. int retval;
  2997. unsigned char data[2];
  2998. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  2999. retval = f54->fn_ptr->read(rmi4_data,
  3000. f54->data_base_addr + DATA_REPORT_INDEX_OFFSET,
  3001. data,
  3002. sizeof(data));
  3003. if (retval < 0) {
  3004. dev_err(&rmi4_data->i2c_client->dev,
  3005. "%s: Failed to read data registers\n",
  3006. __func__);
  3007. return retval;
  3008. }
  3009. batohs(&f54->fifoindex, data);
  3010. return snprintf(buf, PAGE_SIZE, "%u\n", f54->fifoindex);
  3011. }
  3012. static ssize_t synaptics_rmi4_f54_fifoindex_store(struct device *dev,
  3013. struct device_attribute *attr, const char *buf, size_t count)
  3014. {
  3015. int retval;
  3016. unsigned char data[2];
  3017. unsigned long setting;
  3018. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3019. retval = kstrtoul(buf, 10, &setting);
  3020. if (retval)
  3021. return retval;
  3022. f54->fifoindex = setting;
  3023. hstoba(data, (unsigned short)setting);
  3024. retval = f54->fn_ptr->write(rmi4_data,
  3025. f54->data_base_addr + DATA_REPORT_INDEX_OFFSET,
  3026. data,
  3027. sizeof(data));
  3028. if (retval < 0) {
  3029. dev_err(&rmi4_data->i2c_client->dev,
  3030. "%s: Failed to write data registers\n",
  3031. __func__);
  3032. return retval;
  3033. }
  3034. return count;
  3035. }
  3036. static ssize_t synaptics_rmi4_f54_do_preparation_store(struct device *dev,
  3037. struct device_attribute *attr, const char *buf, size_t count)
  3038. {
  3039. int retval;
  3040. unsigned long setting;
  3041. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3042. retval = kstrtoul(buf, 10, &setting);
  3043. if (retval)
  3044. return retval;
  3045. if (setting != 1)
  3046. return -EINVAL;
  3047. mutex_lock(&f54->status_mutex);
  3048. if (f54->status != STATUS_IDLE) {
  3049. if (f54->status != STATUS_BUSY) {
  3050. dev_err(&rmi4_data->i2c_client->dev,
  3051. "%s: Invalid status (%d)\n",
  3052. __func__, f54->status);
  3053. } else {
  3054. dev_err(&rmi4_data->i2c_client->dev,
  3055. "%s: Previous get report still ongoing\n",
  3056. __func__);
  3057. }
  3058. mutex_unlock(&f54->status_mutex);
  3059. return -EBUSY;
  3060. }
  3061. mutex_unlock(&f54->status_mutex);
  3062. retval = do_preparation();
  3063. if (retval < 0) {
  3064. dev_err(&rmi4_data->i2c_client->dev,
  3065. "%s: Failed to do preparation\n",
  3066. __func__);
  3067. return retval;
  3068. }
  3069. return count;
  3070. }
  3071. static ssize_t synaptics_rmi4_f54_get_report_store(struct device *dev,
  3072. struct device_attribute *attr, const char *buf, size_t count)
  3073. {
  3074. int retval;
  3075. unsigned char command;
  3076. unsigned long setting;
  3077. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3078. retval = kstrtoul(buf, 10, &setting);
  3079. if (retval)
  3080. return retval;
  3081. if (setting != 1)
  3082. return -EINVAL;
  3083. command = (unsigned char)COMMAND_GET_REPORT;
  3084. if (!is_report_type_valid(f54->report_type)) {
  3085. dev_err(&rmi4_data->i2c_client->dev,
  3086. "%s: Invalid report type\n",
  3087. __func__);
  3088. return -EINVAL;
  3089. }
  3090. mutex_lock(&f54->status_mutex);
  3091. if (f54->status != STATUS_IDLE) {
  3092. if (f54->status != STATUS_BUSY) {
  3093. dev_err(&rmi4_data->i2c_client->dev,
  3094. "%s: Invalid status (%d)\n",
  3095. __func__, f54->status);
  3096. } else {
  3097. dev_err(&rmi4_data->i2c_client->dev,
  3098. "%s: Previous get report still ongoing\n",
  3099. __func__);
  3100. }
  3101. mutex_unlock(&f54->status_mutex);
  3102. return -EBUSY;
  3103. }
  3104. set_interrupt(true);
  3105. f54->status = STATUS_BUSY;
  3106. retval = f54->fn_ptr->write(rmi4_data,
  3107. f54->command_base_addr,
  3108. &command,
  3109. sizeof(command));
  3110. mutex_unlock(&f54->status_mutex);
  3111. if (retval < 0) {
  3112. dev_err(&rmi4_data->i2c_client->dev,
  3113. "%s: Failed to write get report command\n",
  3114. __func__);
  3115. return retval;
  3116. }
  3117. #ifdef WATCHDOG_HRTIMER
  3118. hrtimer_start(&f54->watchdog,
  3119. ktime_set(WATCHDOG_TIMEOUT_S, 0),
  3120. HRTIMER_MODE_REL);
  3121. #endif
  3122. return count;
  3123. }
  3124. static ssize_t synaptics_rmi4_f54_force_cal_store(struct device *dev,
  3125. struct device_attribute *attr, const char *buf, size_t count)
  3126. {
  3127. int retval;
  3128. unsigned char command;
  3129. unsigned long setting;
  3130. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3131. retval = kstrtoul(buf, 10, &setting);
  3132. if (retval)
  3133. return retval;
  3134. if (setting != 1)
  3135. return count;
  3136. command = (unsigned char)COMMAND_FORCE_CAL;
  3137. if (f54->status == STATUS_BUSY)
  3138. return -EBUSY;
  3139. retval = f54->fn_ptr->write(rmi4_data,
  3140. f54->command_base_addr,
  3141. &command,
  3142. sizeof(command));
  3143. if (retval < 0) {
  3144. dev_err(&rmi4_data->i2c_client->dev,
  3145. "%s: Failed to write force cal command\n",
  3146. __func__);
  3147. return retval;
  3148. }
  3149. return count;
  3150. }
  3151. simple_show_func_unsigned(query, num_of_rx_electrodes)
  3152. simple_show_func_unsigned(query, num_of_tx_electrodes)
  3153. simple_show_func_unsigned(query, has_image16)
  3154. simple_show_func_unsigned(query, has_image8)
  3155. simple_show_func_unsigned(query, has_baseline)
  3156. simple_show_func_unsigned(query, clock_rate)
  3157. simple_show_func_unsigned(query, touch_controller_family)
  3158. simple_show_func_unsigned(query, has_pixel_touch_threshold_adjustment)
  3159. simple_show_func_unsigned(query, has_sensor_assignment)
  3160. simple_show_func_unsigned(query, has_interference_metric)
  3161. simple_show_func_unsigned(query, has_sense_frequency_control)
  3162. simple_show_func_unsigned(query, has_firmware_noise_mitigation)
  3163. simple_show_func_unsigned(query, has_two_byte_report_rate)
  3164. simple_show_func_unsigned(query, has_one_byte_report_rate)
  3165. simple_show_func_unsigned(query, has_relaxation_control)
  3166. simple_show_func_unsigned(query, curve_compensation_mode)
  3167. simple_show_func_unsigned(query, has_iir_filter)
  3168. simple_show_func_unsigned(query, has_cmn_removal)
  3169. simple_show_func_unsigned(query, has_cmn_maximum)
  3170. simple_show_func_unsigned(query, has_touch_hysteresis)
  3171. simple_show_func_unsigned(query, has_edge_compensation)
  3172. simple_show_func_unsigned(query, has_per_frequency_noise_control)
  3173. simple_show_func_unsigned(query, has_signal_clarity)
  3174. simple_show_func_unsigned(query, number_of_sensing_frequencies)
  3175. show_store_func_unsigned(control, reg_0, no_relax)
  3176. show_store_func_unsigned(control, reg_0, no_scan)
  3177. show_store_func_unsigned(control, reg_1, bursts_per_cluster)
  3178. show_store_func_unsigned(control, reg_2, saturation_cap)
  3179. show_store_func_unsigned(control, reg_3, pixel_touch_threshold)
  3180. show_store_func_unsigned(control, reg_4__6, rx_feedback_cap)
  3181. show_store_func_unsigned(control, reg_4__6, low_ref_cap)
  3182. show_store_func_unsigned(control, reg_4__6, low_ref_feedback_cap)
  3183. show_store_func_unsigned(control, reg_4__6, low_ref_polarity)
  3184. show_store_func_unsigned(control, reg_4__6, high_ref_cap)
  3185. show_store_func_unsigned(control, reg_4__6, high_ref_feedback_cap)
  3186. show_store_func_unsigned(control, reg_4__6, high_ref_polarity)
  3187. show_store_func_unsigned(control, reg_7, cbc_cap)
  3188. show_store_func_unsigned(control, reg_7, cbc_polarity)
  3189. show_store_func_unsigned(control, reg_7, cbc_tx_carrier_selection)
  3190. show_store_func_unsigned(control, reg_8__9, integration_duration)
  3191. show_store_func_unsigned(control, reg_8__9, reset_duration)
  3192. show_store_func_unsigned(control, reg_10, noise_sensing_bursts_per_image)
  3193. show_store_func_unsigned(control, reg_12__13, slow_relaxation_rate)
  3194. show_store_func_unsigned(control, reg_12__13, fast_relaxation_rate)
  3195. show_store_func_unsigned(control, reg_14, rxs_on_xaxis)
  3196. show_store_func_unsigned(control, reg_14, curve_comp_on_txs)
  3197. show_store_func_unsigned(control, reg_20, disable_noise_mitigation)
  3198. show_store_func_unsigned(control, reg_21, freq_shift_noise_threshold)
  3199. show_store_func_unsigned(control, reg_22__26, medium_noise_threshold)
  3200. show_store_func_unsigned(control, reg_22__26, high_noise_threshold)
  3201. show_store_func_unsigned(control, reg_22__26, noise_density)
  3202. show_store_func_unsigned(control, reg_22__26, frame_count)
  3203. show_store_func_unsigned(control, reg_27, iir_filter_coef)
  3204. show_store_func_unsigned(control, reg_28, quiet_threshold)
  3205. show_store_func_unsigned(control, reg_29, cmn_filter_disable)
  3206. show_store_func_unsigned(control, reg_30, cmn_filter_max)
  3207. show_store_func_unsigned(control, reg_31, touch_hysteresis)
  3208. show_store_func_unsigned(control, reg_32__35, rx_low_edge_comp)
  3209. show_store_func_unsigned(control, reg_32__35, rx_high_edge_comp)
  3210. show_store_func_unsigned(control, reg_32__35, tx_low_edge_comp)
  3211. show_store_func_unsigned(control, reg_32__35, tx_high_edge_comp)
  3212. show_store_func_unsigned(control, reg_41, no_signal_clarity)
  3213. show_replicated_func_unsigned(control, reg_15, sensor_rx_assignment)
  3214. show_replicated_func_unsigned(control, reg_16, sensor_tx_assignment)
  3215. show_replicated_func_unsigned(control, reg_17, disable)
  3216. show_replicated_func_unsigned(control, reg_17, filter_bandwidth)
  3217. show_replicated_func_unsigned(control, reg_19, stretch_duration)
  3218. show_replicated_func_unsigned(control, reg_38, noise_control_1)
  3219. show_replicated_func_unsigned(control, reg_39, noise_control_2)
  3220. show_replicated_func_unsigned(control, reg_40, noise_control_3)
  3221. show_store_replicated_func_unsigned(control, reg_36, axis1_comp)
  3222. show_store_replicated_func_unsigned(control, reg_37, axis2_comp)
  3223. static ssize_t synaptics_rmi4_f54_burst_count_show(struct device *dev,
  3224. struct device_attribute *attr, char *buf)
  3225. {
  3226. int retval;
  3227. int size = 0;
  3228. unsigned char ii;
  3229. unsigned char *temp;
  3230. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3231. mutex_lock(&f54->control_mutex);
  3232. retval = f54->fn_ptr->read(rmi4_data,
  3233. f54->control.reg_17->address,
  3234. (unsigned char *)f54->control.reg_17->data,
  3235. f54->control.reg_17->length);
  3236. if (retval < 0) {
  3237. dev_dbg(&rmi4_data->i2c_client->dev,
  3238. "%s: Failed to read control reg_17\n",
  3239. __func__);
  3240. }
  3241. retval = f54->fn_ptr->read(rmi4_data,
  3242. f54->control.reg_18->address,
  3243. (unsigned char *)f54->control.reg_18->data,
  3244. f54->control.reg_18->length);
  3245. if (retval < 0) {
  3246. dev_dbg(&rmi4_data->i2c_client->dev,
  3247. "%s: Failed to read control reg_18\n",
  3248. __func__);
  3249. }
  3250. mutex_unlock(&f54->control_mutex);
  3251. temp = buf;
  3252. for (ii = 0; ii < f54->control.reg_17->length; ii++) {
  3253. retval = snprintf(temp, PAGE_SIZE - size, "%u ", (1 << 8) *
  3254. f54->control.reg_17->data[ii].burst_count_b8__10 +
  3255. f54->control.reg_18->data[ii].burst_count_b0__7);
  3256. if (retval < 0) {
  3257. dev_err(&rmi4_data->i2c_client->dev,
  3258. "%s: Faild to write output\n",
  3259. __func__);
  3260. return retval;
  3261. }
  3262. size += retval;
  3263. temp += retval;
  3264. }
  3265. retval = snprintf(temp, PAGE_SIZE - size, "\n");
  3266. if (retval < 0) {
  3267. dev_err(&rmi4_data->i2c_client->dev,
  3268. "%s: Faild to write null terminator\n",
  3269. __func__);
  3270. return retval;
  3271. }
  3272. return size + retval;
  3273. }
  3274. static ssize_t synaptics_rmi4_f54_data_read(struct file *data_file,
  3275. struct kobject *kobj, struct bin_attribute *attributes,
  3276. char *buf, loff_t pos, size_t count)
  3277. {
  3278. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3279. mutex_lock(&f54->data_mutex);
  3280. if (count < f54->report_size) {
  3281. dev_err(&rmi4_data->i2c_client->dev,
  3282. "%s: Report type %d data size (%d) too large\n",
  3283. __func__, f54->report_type, f54->report_size);
  3284. mutex_unlock(&f54->data_mutex);
  3285. return -EINVAL;
  3286. }
  3287. if (f54->report_data) {
  3288. memcpy(buf, f54->report_data, f54->report_size);
  3289. mutex_unlock(&f54->data_mutex);
  3290. return f54->report_size;
  3291. } else {
  3292. dev_err(&rmi4_data->i2c_client->dev,
  3293. "%s: Report type %d data not available\n",
  3294. __func__, f54->report_type);
  3295. mutex_unlock(&f54->data_mutex);
  3296. return -EINVAL;
  3297. }
  3298. }
  3299. static int synaptics_rmi4_f54_set_sysfs(void)
  3300. {
  3301. int retval;
  3302. int reg_num;
  3303. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3304. f54->attr_dir = kobject_create_and_add("f54",
  3305. &rmi4_data->input_dev->dev.kobj);
  3306. if (!f54->attr_dir) {
  3307. dev_err(&rmi4_data->i2c_client->dev,
  3308. "%s: Failed to create sysfs directory\n",
  3309. __func__);
  3310. goto exit_1;
  3311. }
  3312. retval = sysfs_create_bin_file(f54->attr_dir, &dev_report_data);
  3313. if (retval < 0) {
  3314. dev_err(&rmi4_data->i2c_client->dev,
  3315. "%s: Failed to create sysfs bin file\n",
  3316. __func__);
  3317. goto exit_2;
  3318. }
  3319. retval = sysfs_create_group(f54->attr_dir, &attr_group);
  3320. if (retval < 0) {
  3321. dev_err(&rmi4_data->i2c_client->dev,
  3322. "%s: Failed to create sysfs attributes\n",
  3323. __func__);
  3324. goto exit_3;
  3325. }
  3326. for (reg_num = 0; reg_num < ARRAY_SIZE(attrs_ctrl_regs); reg_num++) {
  3327. if (attrs_ctrl_regs_exist[reg_num]) {
  3328. retval = sysfs_create_group(f54->attr_dir,
  3329. &attrs_ctrl_regs[reg_num]);
  3330. if (retval < 0) {
  3331. dev_err(&rmi4_data->i2c_client->dev,
  3332. "%s: Failed to create sysfs attributes\n",
  3333. __func__);
  3334. goto exit_4;
  3335. }
  3336. }
  3337. }
  3338. return 0;
  3339. exit_4:
  3340. sysfs_remove_group(f54->attr_dir, &attr_group);
  3341. for (reg_num--; reg_num >= 0; reg_num--)
  3342. sysfs_remove_group(f54->attr_dir, &attrs_ctrl_regs[reg_num]);
  3343. exit_3:
  3344. sysfs_remove_bin_file(f54->attr_dir, &dev_report_data);
  3345. exit_2:
  3346. kobject_put(f54->attr_dir);
  3347. exit_1:
  3348. return -ENODEV;
  3349. }
  3350. static int synaptics_rmi4_f54_set_ctrl(void)
  3351. {
  3352. unsigned char length;
  3353. unsigned char reg_num = 0;
  3354. unsigned char num_of_sensing_freqs;
  3355. unsigned short reg_addr = f54->control_base_addr;
  3356. struct f54_control *control = &f54->control;
  3357. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3358. num_of_sensing_freqs = f54->query.number_of_sensing_frequencies;
  3359. /* control 0 */
  3360. attrs_ctrl_regs_exist[reg_num] = true;
  3361. control->reg_0 = kzalloc(sizeof(*(control->reg_0)),
  3362. GFP_KERNEL);
  3363. if (!control->reg_0)
  3364. goto exit_no_mem;
  3365. control->reg_0->address = reg_addr;
  3366. reg_addr += sizeof(control->reg_0->data);
  3367. reg_num++;
  3368. /* control 1 */
  3369. if ((f54->query.touch_controller_family == 0) ||
  3370. (f54->query.touch_controller_family == 1)) {
  3371. attrs_ctrl_regs_exist[reg_num] = true;
  3372. control->reg_1 = kzalloc(sizeof(*(control->reg_1)),
  3373. GFP_KERNEL);
  3374. if (!control->reg_1)
  3375. goto exit_no_mem;
  3376. control->reg_1->address = reg_addr;
  3377. reg_addr += sizeof(control->reg_1->data);
  3378. }
  3379. reg_num++;
  3380. /* control 2 */
  3381. attrs_ctrl_regs_exist[reg_num] = true;
  3382. control->reg_2 = kzalloc(sizeof(*(control->reg_2)),
  3383. GFP_KERNEL);
  3384. if (!control->reg_2)
  3385. goto exit_no_mem;
  3386. control->reg_2->address = reg_addr;
  3387. reg_addr += sizeof(control->reg_2->data);
  3388. reg_num++;
  3389. /* control 3 */
  3390. if (f54->query.has_pixel_touch_threshold_adjustment == 1) {
  3391. attrs_ctrl_regs_exist[reg_num] = true;
  3392. control->reg_3 = kzalloc(sizeof(*(control->reg_3)),
  3393. GFP_KERNEL);
  3394. if (!control->reg_3)
  3395. goto exit_no_mem;
  3396. control->reg_3->address = reg_addr;
  3397. reg_addr += sizeof(control->reg_3->data);
  3398. }
  3399. reg_num++;
  3400. /* controls 4 5 6 */
  3401. if ((f54->query.touch_controller_family == 0) ||
  3402. (f54->query.touch_controller_family == 1)) {
  3403. attrs_ctrl_regs_exist[reg_num] = true;
  3404. control->reg_4__6 = kzalloc(sizeof(*(control->reg_4__6)),
  3405. GFP_KERNEL);
  3406. if (!control->reg_4__6)
  3407. goto exit_no_mem;
  3408. control->reg_4__6->address = reg_addr;
  3409. reg_addr += sizeof(control->reg_4__6->data);
  3410. }
  3411. reg_num++;
  3412. /* control 7 */
  3413. if (f54->query.touch_controller_family == 1) {
  3414. attrs_ctrl_regs_exist[reg_num] = true;
  3415. control->reg_7 = kzalloc(sizeof(*(control->reg_7)),
  3416. GFP_KERNEL);
  3417. if (!control->reg_7)
  3418. goto exit_no_mem;
  3419. control->reg_7->address = reg_addr;
  3420. reg_addr += sizeof(control->reg_7->data);
  3421. }
  3422. reg_num++;
  3423. /* controls 8 9 */
  3424. if ((f54->query.touch_controller_family == 0) ||
  3425. (f54->query.touch_controller_family == 1)) {
  3426. attrs_ctrl_regs_exist[reg_num] = true;
  3427. control->reg_8__9 = kzalloc(sizeof(*(control->reg_8__9)),
  3428. GFP_KERNEL);
  3429. if (!control->reg_8__9)
  3430. goto exit_no_mem;
  3431. control->reg_8__9->address = reg_addr;
  3432. reg_addr += sizeof(control->reg_8__9->data);
  3433. }
  3434. reg_num++;
  3435. /* control 10 */
  3436. if (f54->query.has_interference_metric == 1) {
  3437. attrs_ctrl_regs_exist[reg_num] = true;
  3438. control->reg_10 = kzalloc(sizeof(*(control->reg_10)),
  3439. GFP_KERNEL);
  3440. if (!control->reg_10)
  3441. goto exit_no_mem;
  3442. control->reg_10->address = reg_addr;
  3443. reg_addr += sizeof(control->reg_10->data);
  3444. }
  3445. reg_num++;
  3446. /* control 11 */
  3447. if (f54->query.has_ctrl11 == 1) {
  3448. attrs_ctrl_regs_exist[reg_num] = true;
  3449. control->reg_11 = kzalloc(sizeof(*(control->reg_11)),
  3450. GFP_KERNEL);
  3451. if (!control->reg_11)
  3452. goto exit_no_mem;
  3453. control->reg_11->address = reg_addr;
  3454. reg_addr += sizeof(control->reg_11->data);
  3455. }
  3456. reg_num++;
  3457. /* controls 12 13 */
  3458. if (f54->query.has_relaxation_control == 1) {
  3459. attrs_ctrl_regs_exist[reg_num] = true;
  3460. control->reg_12__13 = kzalloc(sizeof(*(control->reg_12__13)),
  3461. GFP_KERNEL);
  3462. if (!control->reg_12__13)
  3463. goto exit_no_mem;
  3464. control->reg_12__13->address = reg_addr;
  3465. reg_addr += sizeof(control->reg_12__13->data);
  3466. }
  3467. reg_num++;
  3468. /* controls 14 15 16 */
  3469. if (f54->query.has_sensor_assignment == 1) {
  3470. attrs_ctrl_regs_exist[reg_num] = true;
  3471. control->reg_14 = kzalloc(sizeof(*(control->reg_14)),
  3472. GFP_KERNEL);
  3473. if (!control->reg_14)
  3474. goto exit_no_mem;
  3475. control->reg_14->address = reg_addr;
  3476. reg_addr += sizeof(control->reg_14->data);
  3477. control->reg_15 = kzalloc(sizeof(*(control->reg_15)),
  3478. GFP_KERNEL);
  3479. if (!control->reg_15)
  3480. goto exit_no_mem;
  3481. control->reg_15->length = f54->query.num_of_rx_electrodes;
  3482. control->reg_15->data = kzalloc(control->reg_15->length *
  3483. sizeof(*(control->reg_15->data)), GFP_KERNEL);
  3484. if (!control->reg_15->data)
  3485. goto exit_no_mem;
  3486. control->reg_15->address = reg_addr;
  3487. reg_addr += control->reg_15->length;
  3488. control->reg_16 = kzalloc(sizeof(*(control->reg_16)),
  3489. GFP_KERNEL);
  3490. if (!control->reg_16)
  3491. goto exit_no_mem;
  3492. control->reg_16->length = f54->query.num_of_tx_electrodes;
  3493. control->reg_16->data = kzalloc(control->reg_16->length *
  3494. sizeof(*(control->reg_16->data)), GFP_KERNEL);
  3495. if (!control->reg_16->data)
  3496. goto exit_no_mem;
  3497. control->reg_16->address = reg_addr;
  3498. reg_addr += control->reg_16->length;
  3499. }
  3500. reg_num++;
  3501. /* controls 17 18 19 */
  3502. if (f54->query.has_sense_frequency_control == 1) {
  3503. attrs_ctrl_regs_exist[reg_num] = true;
  3504. length = num_of_sensing_freqs;
  3505. control->reg_17 = kzalloc(sizeof(*(control->reg_17)),
  3506. GFP_KERNEL);
  3507. if (!control->reg_17)
  3508. goto exit_no_mem;
  3509. control->reg_17->length = length;
  3510. control->reg_17->data = kzalloc(length *
  3511. sizeof(*(control->reg_17->data)), GFP_KERNEL);
  3512. if (!control->reg_17->data)
  3513. goto exit_no_mem;
  3514. control->reg_17->address = reg_addr;
  3515. reg_addr += length;
  3516. control->reg_18 = kzalloc(sizeof(*(control->reg_18)),
  3517. GFP_KERNEL);
  3518. if (!control->reg_18)
  3519. goto exit_no_mem;
  3520. control->reg_18->length = length;
  3521. control->reg_18->data = kzalloc(length *
  3522. sizeof(*(control->reg_18->data)), GFP_KERNEL);
  3523. if (!control->reg_18->data)
  3524. goto exit_no_mem;
  3525. control->reg_18->address = reg_addr;
  3526. reg_addr += length;
  3527. control->reg_19 = kzalloc(sizeof(*(control->reg_19)),
  3528. GFP_KERNEL);
  3529. if (!control->reg_19)
  3530. goto exit_no_mem;
  3531. control->reg_19->length = length;
  3532. control->reg_19->data = kzalloc(length *
  3533. sizeof(*(control->reg_19->data)), GFP_KERNEL);
  3534. if (!control->reg_19->data)
  3535. goto exit_no_mem;
  3536. control->reg_19->address = reg_addr;
  3537. reg_addr += length;
  3538. }
  3539. reg_num++;
  3540. /* control 20 */
  3541. attrs_ctrl_regs_exist[reg_num] = true;
  3542. control->reg_20 = kzalloc(sizeof(*(control->reg_20)),
  3543. GFP_KERNEL);
  3544. if (!control->reg_20)
  3545. goto exit_no_mem;
  3546. control->reg_20->address = reg_addr;
  3547. reg_addr += sizeof(control->reg_20->data);
  3548. reg_num++;
  3549. /* control 21 */
  3550. if (f54->query.has_sense_frequency_control == 1) {
  3551. attrs_ctrl_regs_exist[reg_num] = true;
  3552. control->reg_21 = kzalloc(sizeof(*(control->reg_21)),
  3553. GFP_KERNEL);
  3554. if (!control->reg_21)
  3555. goto exit_no_mem;
  3556. control->reg_21->address = reg_addr;
  3557. reg_addr += sizeof(control->reg_21->data);
  3558. }
  3559. reg_num++;
  3560. /* controls 22 23 24 25 26 */
  3561. if (f54->query.has_firmware_noise_mitigation == 1) {
  3562. attrs_ctrl_regs_exist[reg_num] = true;
  3563. control->reg_22__26 = kzalloc(sizeof(*(control->reg_22__26)),
  3564. GFP_KERNEL);
  3565. if (!control->reg_22__26)
  3566. goto exit_no_mem;
  3567. control->reg_22__26->address = reg_addr;
  3568. reg_addr += sizeof(control->reg_22__26->data);
  3569. }
  3570. reg_num++;
  3571. /* control 27 */
  3572. if (f54->query.has_iir_filter == 1) {
  3573. attrs_ctrl_regs_exist[reg_num] = true;
  3574. control->reg_27 = kzalloc(sizeof(*(control->reg_27)),
  3575. GFP_KERNEL);
  3576. if (!control->reg_27)
  3577. goto exit_no_mem;
  3578. control->reg_27->address = reg_addr;
  3579. reg_addr += sizeof(control->reg_27->data);
  3580. }
  3581. reg_num++;
  3582. /* control 28 */
  3583. if (f54->query.has_firmware_noise_mitigation == 1) {
  3584. attrs_ctrl_regs_exist[reg_num] = true;
  3585. control->reg_28 = kzalloc(sizeof(*(control->reg_28)),
  3586. GFP_KERNEL);
  3587. if (!control->reg_28)
  3588. goto exit_no_mem;
  3589. control->reg_28->address = reg_addr;
  3590. reg_addr += sizeof(control->reg_28->data);
  3591. }
  3592. reg_num++;
  3593. /* control 29 */
  3594. if (f54->query.has_cmn_removal == 1) {
  3595. attrs_ctrl_regs_exist[reg_num] = true;
  3596. control->reg_29 = kzalloc(sizeof(*(control->reg_29)),
  3597. GFP_KERNEL);
  3598. if (!control->reg_29)
  3599. goto exit_no_mem;
  3600. control->reg_29->address = reg_addr;
  3601. reg_addr += sizeof(control->reg_29->data);
  3602. }
  3603. reg_num++;
  3604. /* control 30 */
  3605. if (f54->query.has_cmn_maximum == 1) {
  3606. attrs_ctrl_regs_exist[reg_num] = true;
  3607. control->reg_30 = kzalloc(sizeof(*(control->reg_30)),
  3608. GFP_KERNEL);
  3609. if (!control->reg_30)
  3610. goto exit_no_mem;
  3611. control->reg_30->address = reg_addr;
  3612. reg_addr += sizeof(control->reg_30->data);
  3613. }
  3614. reg_num++;
  3615. /* control 31 */
  3616. if (f54->query.has_touch_hysteresis == 1) {
  3617. attrs_ctrl_regs_exist[reg_num] = true;
  3618. control->reg_31 = kzalloc(sizeof(*(control->reg_31)),
  3619. GFP_KERNEL);
  3620. if (!control->reg_31)
  3621. goto exit_no_mem;
  3622. control->reg_31->address = reg_addr;
  3623. reg_addr += sizeof(control->reg_31->data);
  3624. }
  3625. reg_num++;
  3626. /* controls 32 33 34 35 */
  3627. if (f54->query.has_edge_compensation == 1) {
  3628. attrs_ctrl_regs_exist[reg_num] = true;
  3629. control->reg_32__35 = kzalloc(sizeof(*(control->reg_32__35)),
  3630. GFP_KERNEL);
  3631. if (!control->reg_32__35)
  3632. goto exit_no_mem;
  3633. control->reg_32__35->address = reg_addr;
  3634. reg_addr += sizeof(control->reg_32__35->data);
  3635. }
  3636. reg_num++;
  3637. /* control 36 */
  3638. if ((f54->query.curve_compensation_mode == 1) ||
  3639. (f54->query.curve_compensation_mode == 2)) {
  3640. attrs_ctrl_regs_exist[reg_num] = true;
  3641. if (f54->query.curve_compensation_mode == 1) {
  3642. length = max(f54->query.num_of_rx_electrodes,
  3643. f54->query.num_of_tx_electrodes);
  3644. } else if (f54->query.curve_compensation_mode == 2) {
  3645. length = f54->query.num_of_rx_electrodes;
  3646. }
  3647. control->reg_36 = kzalloc(sizeof(*(control->reg_36)),
  3648. GFP_KERNEL);
  3649. if (!control->reg_36)
  3650. goto exit_no_mem;
  3651. control->reg_36->length = length;
  3652. control->reg_36->data = kzalloc(length *
  3653. sizeof(*(control->reg_36->data)), GFP_KERNEL);
  3654. if (!control->reg_36->data)
  3655. goto exit_no_mem;
  3656. control->reg_36->address = reg_addr;
  3657. reg_addr += length;
  3658. }
  3659. reg_num++;
  3660. /* control 37 */
  3661. if (f54->query.curve_compensation_mode == 2) {
  3662. attrs_ctrl_regs_exist[reg_num] = true;
  3663. control->reg_37 = kzalloc(sizeof(*(control->reg_37)),
  3664. GFP_KERNEL);
  3665. if (!control->reg_37)
  3666. goto exit_no_mem;
  3667. control->reg_37->length = f54->query.num_of_tx_electrodes;
  3668. control->reg_37->data = kzalloc(control->reg_37->length *
  3669. sizeof(*(control->reg_37->data)), GFP_KERNEL);
  3670. if (!control->reg_37->data)
  3671. goto exit_no_mem;
  3672. control->reg_37->address = reg_addr;
  3673. reg_addr += control->reg_37->length;
  3674. }
  3675. reg_num++;
  3676. /* controls 38 39 40 */
  3677. if (f54->query.has_per_frequency_noise_control == 1) {
  3678. attrs_ctrl_regs_exist[reg_num] = true;
  3679. control->reg_38 = kzalloc(sizeof(*(control->reg_38)),
  3680. GFP_KERNEL);
  3681. if (!control->reg_38)
  3682. goto exit_no_mem;
  3683. control->reg_38->length = num_of_sensing_freqs;
  3684. control->reg_38->data = kzalloc(control->reg_38->length *
  3685. sizeof(*(control->reg_38->data)), GFP_KERNEL);
  3686. if (!control->reg_38->data)
  3687. goto exit_no_mem;
  3688. control->reg_38->address = reg_addr;
  3689. reg_addr += control->reg_38->length;
  3690. control->reg_39 = kzalloc(sizeof(*(control->reg_39)),
  3691. GFP_KERNEL);
  3692. if (!control->reg_39)
  3693. goto exit_no_mem;
  3694. control->reg_39->length = num_of_sensing_freqs;
  3695. control->reg_39->data = kzalloc(control->reg_39->length *
  3696. sizeof(*(control->reg_39->data)), GFP_KERNEL);
  3697. if (!control->reg_39->data)
  3698. goto exit_no_mem;
  3699. control->reg_39->address = reg_addr;
  3700. reg_addr += control->reg_39->length;
  3701. control->reg_40 = kzalloc(sizeof(*(control->reg_40)),
  3702. GFP_KERNEL);
  3703. if (!control->reg_40)
  3704. goto exit_no_mem;
  3705. control->reg_40->length = num_of_sensing_freqs;
  3706. control->reg_40->data = kzalloc(control->reg_40->length *
  3707. sizeof(*(control->reg_40->data)), GFP_KERNEL);
  3708. if (!control->reg_40->data)
  3709. goto exit_no_mem;
  3710. control->reg_40->address = reg_addr;
  3711. reg_addr += control->reg_40->length;
  3712. }
  3713. reg_num++;
  3714. /* control 41 */
  3715. if (f54->query.has_signal_clarity == 1) {
  3716. attrs_ctrl_regs_exist[reg_num] = true;
  3717. control->reg_41 = kzalloc(sizeof(*(control->reg_41)),
  3718. GFP_KERNEL);
  3719. if (!control->reg_41)
  3720. goto exit_no_mem;
  3721. control->reg_41->address = reg_addr;
  3722. reg_addr += sizeof(control->reg_41->data);
  3723. }
  3724. reg_num++;
  3725. return 0;
  3726. exit_no_mem:
  3727. dev_err(&rmi4_data->i2c_client->dev,
  3728. "%s: Failed to alloc mem for control registers\n",
  3729. __func__);
  3730. return -ENOMEM;
  3731. }
  3732. #ifdef FACTORY_MODE
  3733. static int synaptics_rmi4_f54_get_report_type(int type)
  3734. {
  3735. int retval;
  3736. char buf[3];
  3737. unsigned char patience = 5;
  3738. memset(buf, 0x00, sizeof(buf));
  3739. snprintf(buf, 3, "%u\n", type);
  3740. retval = synaptics_rmi4_f54_report_type_store(NULL, NULL, buf, 2);
  3741. if (retval != 2)
  3742. return 0;
  3743. memset(buf, 0x00, sizeof(buf));
  3744. snprintf(buf, 3, "%u\n", CMD_GET_REPORT);
  3745. retval = synaptics_rmi4_f54_get_report_store(NULL, NULL, buf, 2);
  3746. if (retval != 2)
  3747. return 0;
  3748. do {
  3749. msleep(1000);
  3750. if (f54->status == STATUS_IDLE)
  3751. break;
  3752. } while (--patience > 0);
  3753. if ((f54->report_size == 0) || (f54->status != STATUS_IDLE))
  3754. return 0;
  3755. else
  3756. return 1;
  3757. }
  3758. #endif
  3759. static void synaptics_rmi4_f54_status_work(struct work_struct *work)
  3760. {
  3761. int retval;
  3762. unsigned char report_index[2];
  3763. struct synaptics_rmi4_data *rmi4_data = f54->rmi4_data;
  3764. if (f54->status != STATUS_BUSY)
  3765. return;
  3766. set_report_size();
  3767. if (f54->report_size == 0) {
  3768. dev_err(&rmi4_data->i2c_client->dev,
  3769. "%s: Report data size = 0\n",
  3770. __func__);
  3771. retval = -EINVAL;
  3772. goto error_exit;
  3773. }
  3774. if (f54->data_buffer_size < f54->report_size) {
  3775. mutex_lock(&f54->data_mutex);
  3776. if (f54->data_buffer_size)
  3777. kfree(f54->report_data);
  3778. f54->report_data = kzalloc(f54->report_size, GFP_KERNEL);
  3779. if (!f54->report_data) {
  3780. dev_err(&rmi4_data->i2c_client->dev,
  3781. "%s: Failed to alloc mem for data buffer\n",
  3782. __func__);
  3783. f54->data_buffer_size = 0;
  3784. mutex_unlock(&f54->data_mutex);
  3785. retval = -ENOMEM;
  3786. goto error_exit;
  3787. }
  3788. f54->data_buffer_size = f54->report_size;
  3789. mutex_unlock(&f54->data_mutex);
  3790. }
  3791. report_index[0] = 0;
  3792. report_index[1] = 0;
  3793. retval = f54->fn_ptr->write(rmi4_data,
  3794. f54->data_base_addr + DATA_REPORT_INDEX_OFFSET,
  3795. report_index,
  3796. sizeof(report_index));
  3797. if (retval < 0) {
  3798. dev_err(&rmi4_data->i2c_client->dev,
  3799. "%s: Failed to write report data index\n",
  3800. __func__);
  3801. retval = -EINVAL;
  3802. goto error_exit;
  3803. }
  3804. retval = f54->fn_ptr->read(rmi4_data,
  3805. f54->data_base_addr + DATA_REPORT_DATA_OFFSET,
  3806. f54->report_data,
  3807. f54->report_size);
  3808. if (retval < 0) {
  3809. dev_err(&rmi4_data->i2c_client->dev,
  3810. "%s: Failed to read report data\n",
  3811. __func__);
  3812. retval = -EINVAL;
  3813. goto error_exit;
  3814. }
  3815. retval = STATUS_IDLE;
  3816. #ifdef RAW_HEX
  3817. print_raw_hex_report();
  3818. #endif
  3819. #ifdef HUMAN_READABLE
  3820. print_image_report();
  3821. #endif
  3822. error_exit:
  3823. mutex_lock(&f54->status_mutex);
  3824. set_interrupt(false);
  3825. f54->status = retval;
  3826. mutex_unlock(&f54->status_mutex);
  3827. return;
  3828. }
  3829. static void synaptics_rmi4_f54_attn(struct synaptics_rmi4_data *rmi4_data,
  3830. unsigned char intr_mask)
  3831. {
  3832. if (f54->intr_mask & intr_mask) {
  3833. queue_delayed_work(f54->status_workqueue,
  3834. &f54->status_work,
  3835. msecs_to_jiffies(STATUS_WORK_INTERVAL));
  3836. }
  3837. return;
  3838. }
  3839. int synaptics_rmi4_f54_set_control(struct synaptics_rmi4_data *rmi4_data)
  3840. {
  3841. int retval;
  3842. unsigned short ii;
  3843. unsigned char page;
  3844. unsigned char intr_count = 0;
  3845. unsigned char intr_offset;
  3846. struct synaptics_rmi4_fn_desc rmi_fd;
  3847. f54->rmi4_data = rmi4_data;
  3848. f54->fn_ptr->read = rmi4_data->i2c_read;
  3849. f54->fn_ptr->write = rmi4_data->i2c_write;
  3850. f54->fn_ptr->enable = rmi4_data->irq_enable;
  3851. for (page = 0; page < PAGES_TO_SERVICE; page++) {
  3852. for (ii = PDT_START; ii > PDT_END; ii -= PDT_ENTRY_SIZE) {
  3853. ii |= (page << 8);
  3854. retval = f54->fn_ptr->read(rmi4_data,
  3855. ii,
  3856. (unsigned char *)&rmi_fd,
  3857. sizeof(rmi_fd));
  3858. if (retval < 0)
  3859. goto err_out;
  3860. if (!rmi_fd.fn_number)
  3861. break;
  3862. if (rmi_fd.fn_number == SYNAPTICS_RMI4_F54)
  3863. goto f54_found;
  3864. intr_count += (rmi_fd.intr_src_count & MASK_3BIT);
  3865. }
  3866. }
  3867. f54_found:
  3868. f54->query_base_addr = rmi_fd.query_base_addr | (page << 8);
  3869. f54->control_base_addr = rmi_fd.ctrl_base_addr | (page << 8);
  3870. f54->data_base_addr = rmi_fd.data_base_addr | (page << 8);
  3871. f54->command_base_addr = rmi_fd.cmd_base_addr | (page << 8);
  3872. dev_info(&rmi4_data->i2c_client->dev,
  3873. "%s: query_base_addr[0x%x] control_base_addr[0x%x] data_base_addr[0x%x] command_base_addr[0x%x]\n",
  3874. __func__, f54->query_base_addr, f54->control_base_addr, f54->data_base_addr, f54->command_base_addr);
  3875. f54->intr_reg_num = (intr_count + 7) / 8;
  3876. if (f54->intr_reg_num != 0)
  3877. f54->intr_reg_num -= 1;
  3878. f54->intr_mask = 0;
  3879. intr_offset = intr_count % 8;
  3880. for (ii = intr_offset;
  3881. ii < ((rmi_fd.intr_src_count & MASK_3BIT) +
  3882. intr_offset);
  3883. ii++) {
  3884. f54->intr_mask |= 1 << ii;
  3885. }
  3886. retval = f54->fn_ptr->read(rmi4_data,
  3887. f54->query_base_addr,
  3888. f54->query.data,
  3889. sizeof(f54->query.data));
  3890. if (retval < 0) {
  3891. dev_err(&rmi4_data->i2c_client->dev,
  3892. "%s: Failed to read query registers\n",
  3893. __func__);
  3894. goto err_out;
  3895. }
  3896. retval = synaptics_rmi4_f54_set_ctrl();
  3897. if (retval < 0) {
  3898. dev_err(&rmi4_data->i2c_client->dev,
  3899. "%s: Failed to set up control registers\n",
  3900. __func__);
  3901. goto err_out;
  3902. }
  3903. return 0;
  3904. err_out:
  3905. return retval;
  3906. }
  3907. static int synaptics_rmi4_f54_init(struct synaptics_rmi4_data *rmi4_data)
  3908. {
  3909. int retval;
  3910. unsigned short ii;
  3911. #ifdef FACTORY_MODE
  3912. unsigned char rx = rmi4_data->num_of_rx;
  3913. unsigned char tx = rmi4_data->num_of_tx;
  3914. struct factory_data *factory_data;
  3915. #endif
  3916. f54 = kzalloc(sizeof(*f54), GFP_KERNEL);
  3917. if (!f54) {
  3918. dev_err(&rmi4_data->i2c_client->dev,
  3919. "%s: Failed to alloc mem for f54\n",
  3920. __func__);
  3921. retval = -ENOMEM;
  3922. goto exit;
  3923. }
  3924. f54->fn_ptr = kzalloc(sizeof(*(f54->fn_ptr)), GFP_KERNEL);
  3925. if (!f54->fn_ptr) {
  3926. dev_err(&rmi4_data->i2c_client->dev,
  3927. "%s: Failed to alloc mem for fn_ptr\n",
  3928. __func__);
  3929. retval = -ENOMEM;
  3930. goto exit_free_f54;
  3931. }
  3932. retval = synaptics_rmi4_f54_set_control(rmi4_data);
  3933. if (retval < 0) {
  3934. dev_err(&rmi4_data->i2c_client->dev,
  3935. "%s: Failed to control f54.\n",
  3936. __func__);
  3937. goto exit_free_control;
  3938. }
  3939. mutex_init(&f54->status_mutex);
  3940. mutex_init(&f54->data_mutex);
  3941. mutex_init(&f54->control_mutex);
  3942. retval = synaptics_rmi4_f54_set_sysfs();
  3943. if (retval < 0) {
  3944. dev_err(&rmi4_data->i2c_client->dev,
  3945. "%s: Failed to create sysfs entries\n",
  3946. __func__);
  3947. goto exit_sysfs;
  3948. }
  3949. #ifdef FACTORY_MODE
  3950. factory_data = kzalloc(sizeof(*factory_data), GFP_KERNEL);
  3951. if (!factory_data) {
  3952. dev_err(&rmi4_data->i2c_client->dev,
  3953. "%s: Failed to alloc mem for factory_data\n",
  3954. __func__);
  3955. retval = -ENOMEM;
  3956. goto exit_factory_data;
  3957. }
  3958. factory_data->rawcap_data = kzalloc(2 * rx * tx, GFP_KERNEL);
  3959. if (!factory_data->rawcap_data) {
  3960. dev_err(&rmi4_data->i2c_client->dev,
  3961. "%s: Failed to alloc mem for rawcap_data\n",
  3962. __func__);
  3963. retval = -ENOMEM;
  3964. goto exit_rawcap_data;
  3965. }
  3966. factory_data->delta_data = kzalloc(2 * rx * tx, GFP_KERNEL);
  3967. if (!factory_data->delta_data) {
  3968. dev_err(&rmi4_data->i2c_client->dev,
  3969. "%s: Failed to alloc mem for delta_data\n",
  3970. __func__);
  3971. retval = -ENOMEM;
  3972. goto exit_delta_data;
  3973. }
  3974. factory_data->abscap_data = kzalloc(4 * rx * tx, GFP_KERNEL);
  3975. if (!factory_data->abscap_data) {
  3976. dev_err(&rmi4_data->i2c_client->dev,
  3977. "%s: Failed to alloc mem for abscap_data\n",
  3978. __func__);
  3979. retval = -ENOMEM;
  3980. goto exit_abscap_data;
  3981. }
  3982. factory_data->absdelta_data = kzalloc(4 * rx * tx, GFP_KERNEL);
  3983. if (!factory_data->abscap_data) {
  3984. dev_err(&rmi4_data->i2c_client->dev,
  3985. "%s: Failed to alloc mem for abscap_data\n",
  3986. __func__);
  3987. retval = -ENOMEM;
  3988. goto exit_absdelta_data;
  3989. }
  3990. factory_data->trx_short = kzalloc(TREX_DATA_SIZE, GFP_KERNEL);
  3991. if (!factory_data->trx_short) {
  3992. dev_err(&rmi4_data->i2c_client->dev,
  3993. "%s: Failed to alloc mem for trx_short\n",
  3994. __func__);
  3995. retval = -ENOMEM;
  3996. goto exit_trx_short;
  3997. }
  3998. INIT_LIST_HEAD(&factory_data->cmd_list_head);
  3999. for (ii = 0; ii < ARRAY_SIZE(ft_cmds); ii++)
  4000. list_add_tail(&ft_cmds[ii].list, &factory_data->cmd_list_head);
  4001. mutex_init(&factory_data->cmd_lock);
  4002. factory_data->cmd_is_running = false;
  4003. factory_data->fac_dev_ts = device_create(sec_class,
  4004. NULL, 0, f54, "tsp");
  4005. retval = IS_ERR(factory_data->fac_dev_ts);
  4006. if (retval) {
  4007. dev_err(&rmi4_data->i2c_client->dev, "%s: Failed to create device for the sysfs\n",
  4008. __func__);
  4009. retval = IS_ERR(factory_data->fac_dev_ts);
  4010. goto exit_cmd_attr_group;
  4011. }
  4012. retval = sysfs_create_group(&factory_data->fac_dev_ts->kobj,
  4013. &cmd_attr_group);
  4014. if (retval < 0) {
  4015. dev_err(&rmi4_data->i2c_client->dev,
  4016. "%s: Failed to create sysfs attributes\n",
  4017. __func__);
  4018. goto exit_cmd_attr_group;
  4019. }
  4020. retval = sysfs_create_link(&factory_data->fac_dev_ts->kobj,
  4021. &rmi4_data->input_dev->dev.kobj, "input");
  4022. if (retval < 0) {
  4023. dev_err(&rmi4_data->i2c_client->dev,
  4024. "%s: Failed to create link\n", __func__);
  4025. }
  4026. f54->factory_data = factory_data;
  4027. #endif
  4028. f54->status_workqueue =
  4029. create_singlethread_workqueue("f54_status_workqueue");
  4030. INIT_DELAYED_WORK(&f54->status_work,
  4031. synaptics_rmi4_f54_status_work);
  4032. #ifdef WATCHDOG_HRTIMER
  4033. /* Watchdog timer to catch unanswered get report commands */
  4034. hrtimer_init(&f54->watchdog, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  4035. f54->watchdog.function = get_report_timeout;
  4036. /* Work function to do actual cleaning up */
  4037. INIT_WORK(&f54->timeout_work, timeout_set_status);
  4038. #endif
  4039. return 0;
  4040. #ifdef FACTORY_MODE
  4041. exit_cmd_attr_group:
  4042. kfree(factory_data->trx_short);
  4043. kfree(factory_data->abscap_data);
  4044. kfree(factory_data->absdelta_data);
  4045. kfree(factory_data->rawcap_data);
  4046. kfree(factory_data->delta_data);
  4047. exit_trx_short:
  4048. exit_absdelta_data:
  4049. exit_abscap_data:
  4050. exit_delta_data:
  4051. exit_rawcap_data:
  4052. kfree(factory_data);
  4053. exit_factory_data:
  4054. remove_sysfs();
  4055. #endif
  4056. exit_sysfs:
  4057. exit_free_control:
  4058. free_control_mem();
  4059. kfree(f54->fn_ptr);
  4060. exit_free_f54:
  4061. kfree(f54);
  4062. exit:
  4063. return retval;
  4064. }
  4065. static void synaptics_rmi4_f54_remove(struct synaptics_rmi4_data *rmi4_data)
  4066. {
  4067. if (!f54)
  4068. return;
  4069. #ifdef WATCHDOG_HRTIMER
  4070. hrtimer_cancel(&f54->watchdog);
  4071. #endif
  4072. cancel_delayed_work_sync(&f54->status_work);
  4073. flush_workqueue(f54->status_workqueue);
  4074. destroy_workqueue(f54->status_workqueue);
  4075. #ifdef FACTORY_MODE
  4076. sysfs_remove_group(&f54->factory_data->fac_dev_ts->kobj, &cmd_attr_group);
  4077. kfree(f54->factory_data->trx_short);
  4078. kfree(f54->factory_data->abscap_data);
  4079. kfree(f54->factory_data->absdelta_data);
  4080. kfree(f54->factory_data->rawcap_data);
  4081. kfree(f54->factory_data->delta_data);
  4082. kfree(f54->factory_data);
  4083. #endif
  4084. remove_sysfs();
  4085. free_control_mem();
  4086. if (f54->data_buffer_size)
  4087. kfree(f54->report_data);
  4088. kfree(f54->fn_ptr);
  4089. kfree(f54);
  4090. f54 = NULL;
  4091. return;
  4092. }
  4093. int rmi4_f54_module_register(void)
  4094. {
  4095. int retval;
  4096. retval = synaptics_rmi4_new_function(RMI_F54,
  4097. synaptics_rmi4_f54_init,
  4098. synaptics_rmi4_f54_remove,
  4099. synaptics_rmi4_f54_attn);
  4100. return retval;
  4101. }