12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332 |
- /*
- * Copyright (C) ST-Ericsson SA 2010
- *
- * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
- * License Terms: GNU General Public License v2
- */
- /*
- * AB8500 register access
- * ======================
- *
- * read:
- * # echo BANK > <debugfs>/ab8500/register-bank
- * # echo ADDR > <debugfs>/ab8500/register-address
- * # cat <debugfs>/ab8500/register-value
- *
- * write:
- * # echo BANK > <debugfs>/ab8500/register-bank
- * # echo ADDR > <debugfs>/ab8500/register-address
- * # echo VALUE > <debugfs>/ab8500/register-value
- *
- * read all registers from a bank:
- * # echo BANK > <debugfs>/ab8500/register-bank
- * # cat <debugfs>/ab8500/all-bank-register
- *
- * BANK target AB8500 register bank
- * ADDR target AB8500 register address
- * VALUE decimal or 0x-prefixed hexadecimal
- *
- *
- * User Space notification on AB8500 IRQ
- * =====================================
- *
- * Allows user space entity to be notified when target AB8500 IRQ occurs.
- * When subscribed, a sysfs entry is created in ab8500.i2c platform device.
- * One can pool this file to get target IRQ occurence information.
- *
- * subscribe to an AB8500 IRQ:
- * # echo IRQ > <debugfs>/ab8500/irq-subscribe
- *
- * unsubscribe from an AB8500 IRQ:
- * # echo IRQ > <debugfs>/ab8500/irq-unsubscribe
- *
- *
- * AB8500 register formated read/write access
- * ==========================================
- *
- * Read: read data, data>>SHIFT, data&=MASK, output data
- * [0xABCDEF98] shift=12 mask=0xFFF => 0x00000CDE
- * Write: read data, data &= ~(MASK<<SHIFT), data |= (VALUE<<SHIFT), write data
- * [0xABCDEF98] shift=12 mask=0xFFF value=0x123 => [0xAB123F98]
- *
- * Usage:
- * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg
- *
- * CMD read read access
- * write write access
- *
- * BANK target reg bank
- * ADDRESS target reg address
- * VALUE (write) value to be updated
- *
- * OPTIONS
- * -d|-dec (read) output in decimal
- * -h|-hexa (read) output in 0x-hexa (default)
- * -l|-w|-b 32bit (default), 16bit or 8bit reg access
- * -m|-mask MASK 0x-hexa mask (default 0xFFFFFFFF)
- * -s|-shift SHIFT bit shift value (read:left, write:right)
- * -o|-offset OFFSET address offset to add to ADDRESS value
- *
- * Warning: bit shift operation is applied to bit-mask.
- * Warning: bit shift direction depends on read or right command.
- */
- #include <linux/seq_file.h>
- #include <linux/uaccess.h>
- #include <linux/fs.h>
- #include <linux/module.h>
- #include <linux/debugfs.h>
- #include <linux/platform_device.h>
- #include <linux/interrupt.h>
- #include <linux/kobject.h>
- #include <linux/slab.h>
- #include <linux/irq.h>
- #include <linux/mfd/abx500.h>
- #include <linux/mfd/abx500/ab8500.h>
- #include <linux/mfd/abx500/ab8500-gpadc.h>
- #ifdef CONFIG_DEBUG_FS
- #include <linux/string.h>
- #include <linux/ctype.h>
- #endif
- static u32 debug_bank;
- static u32 debug_address;
- static int irq_ab8500;
- static int irq_first;
- static int irq_last;
- static u32 *irq_count;
- static int num_irqs;
- static struct device_attribute **dev_attr;
- static char **event_name;
- static u8 avg_sample = SAMPLE_16;
- static u8 trig_edge = RISING_EDGE;
- static u8 conv_type = ADC_SW;
- static u8 trig_timer;
- /**
- * struct ab8500_reg_range
- * @first: the first address of the range
- * @last: the last address of the range
- * @perm: access permissions for the range
- */
- struct ab8500_reg_range {
- u8 first;
- u8 last;
- u8 perm;
- };
- /**
- * struct ab8500_prcmu_ranges
- * @num_ranges: the number of ranges in the list
- * @bankid: bank identifier
- * @range: the list of register ranges
- */
- struct ab8500_prcmu_ranges {
- u8 num_ranges;
- u8 bankid;
- const struct ab8500_reg_range *range;
- };
- /* hwreg- "mask" and "shift" entries ressources */
- struct hwreg_cfg {
- u32 bank; /* target bank */
- unsigned long addr; /* target address */
- uint fmt; /* format */
- unsigned long mask; /* read/write mask, applied before any bit shift */
- long shift; /* bit shift (read:right shift, write:left shift */
- };
- /* fmt bit #0: 0=hexa, 1=dec */
- #define REG_FMT_DEC(c) ((c)->fmt & 0x1)
- #define REG_FMT_HEX(c) (!REG_FMT_DEC(c))
- static struct hwreg_cfg hwreg_cfg = {
- .addr = 0, /* default: invalid phys addr */
- .fmt = 0, /* default: 32bit access, hex output */
- .mask = 0xFFFFFFFF, /* default: no mask */
- .shift = 0, /* default: no bit shift */
- };
- #define AB8500_NAME_STRING "ab8500"
- #define AB8500_ADC_NAME_STRING "gpadc"
- #define AB8500_NUM_BANKS 24
- #define AB8500_REV_REG 0x80
- static struct ab8500_prcmu_ranges *debug_ranges;
- static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = {
- [0x0] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_SYS_CTRL1_BLOCK] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x02,
- },
- {
- .first = 0x42,
- .last = 0x42,
- },
- {
- .first = 0x80,
- .last = 0x81,
- },
- },
- },
- [AB8500_SYS_CTRL2_BLOCK] = {
- .num_ranges = 4,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x0D,
- },
- {
- .first = 0x0F,
- .last = 0x17,
- },
- {
- .first = 0x30,
- .last = 0x30,
- },
- {
- .first = 0x32,
- .last = 0x33,
- },
- },
- },
- [AB8500_REGU_CTRL1] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x03,
- .last = 0x10,
- },
- {
- .first = 0x80,
- .last = 0x84,
- },
- },
- },
- [AB8500_REGU_CTRL2] = {
- .num_ranges = 5,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x15,
- },
- {
- .first = 0x17,
- .last = 0x19,
- },
- {
- .first = 0x1B,
- .last = 0x1D,
- },
- {
- .first = 0x1F,
- .last = 0x22,
- },
- {
- .first = 0x40,
- .last = 0x44,
- },
- /* 0x80-0x8B is SIM registers and should
- * not be accessed from here */
- },
- },
- [AB8500_USB] = {
- .num_ranges = 2,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x80,
- .last = 0x83,
- },
- {
- .first = 0x87,
- .last = 0x8A,
- },
- },
- },
- [AB8500_TVOUT] = {
- .num_ranges = 9,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x12,
- },
- {
- .first = 0x15,
- .last = 0x17,
- },
- {
- .first = 0x19,
- .last = 0x21,
- },
- {
- .first = 0x27,
- .last = 0x2C,
- },
- {
- .first = 0x41,
- .last = 0x41,
- },
- {
- .first = 0x45,
- .last = 0x5B,
- },
- {
- .first = 0x5D,
- .last = 0x5D,
- },
- {
- .first = 0x69,
- .last = 0x69,
- },
- {
- .first = 0x80,
- .last = 0x81,
- },
- },
- },
- [AB8500_DBI] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_ECI_AV_ACC] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x80,
- .last = 0x82,
- },
- },
- },
- [0x9] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_GPADC] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x08,
- },
- },
- },
- [AB8500_CHARGER] = {
- .num_ranges = 9,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x03,
- },
- {
- .first = 0x05,
- .last = 0x05,
- },
- {
- .first = 0x40,
- .last = 0x40,
- },
- {
- .first = 0x42,
- .last = 0x42,
- },
- {
- .first = 0x44,
- .last = 0x44,
- },
- {
- .first = 0x50,
- .last = 0x55,
- },
- {
- .first = 0x80,
- .last = 0x82,
- },
- {
- .first = 0xC0,
- .last = 0xC2,
- },
- {
- .first = 0xf5,
- .last = 0xf6,
- },
- },
- },
- [AB8500_GAS_GAUGE] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x07,
- .last = 0x0A,
- },
- {
- .first = 0x10,
- .last = 0x14,
- },
- },
- },
- [AB8500_DEVELOPMENT] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- },
- },
- [AB8500_DEBUG] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x05,
- .last = 0x07,
- },
- },
- },
- [AB8500_AUDIO] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x6F,
- },
- },
- },
- [AB8500_INTERRUPT] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_RTC] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x0F,
- },
- },
- },
- [AB8500_MISC] = {
- .num_ranges = 8,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x05,
- },
- {
- .first = 0x10,
- .last = 0x15,
- },
- {
- .first = 0x20,
- .last = 0x25,
- },
- {
- .first = 0x30,
- .last = 0x35,
- },
- {
- .first = 0x40,
- .last = 0x45,
- },
- {
- .first = 0x50,
- .last = 0x50,
- },
- {
- .first = 0x60,
- .last = 0x67,
- },
- {
- .first = 0x80,
- .last = 0x80,
- },
- },
- },
- [0x11] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [0x12] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [0x13] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [0x14] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_OTP_EMUL] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x01,
- .last = 0x0F,
- },
- },
- },
- };
- static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = {
- [0x0] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_SYS_CTRL1_BLOCK] = {
- .num_ranges = 5,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x04,
- },
- {
- .first = 0x42,
- .last = 0x42,
- },
- {
- .first = 0x52,
- .last = 0x52,
- },
- {
- .first = 0x54,
- .last = 0x57,
- },
- {
- .first = 0x80,
- .last = 0x83,
- },
- },
- },
- [AB8500_SYS_CTRL2_BLOCK] = {
- .num_ranges = 5,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x0D,
- },
- {
- .first = 0x0F,
- .last = 0x17,
- },
- {
- .first = 0x20,
- .last = 0x20,
- },
- {
- .first = 0x30,
- .last = 0x30,
- },
- {
- .first = 0x32,
- .last = 0x3A,
- },
- },
- },
- [AB8500_REGU_CTRL1] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x03,
- .last = 0x11,
- },
- {
- .first = 0x80,
- .last = 0x86,
- },
- },
- },
- [AB8500_REGU_CTRL2] = {
- .num_ranges = 6,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x06,
- },
- {
- .first = 0x08,
- .last = 0x15,
- },
- {
- .first = 0x17,
- .last = 0x19,
- },
- {
- .first = 0x1B,
- .last = 0x1D,
- },
- {
- .first = 0x1F,
- .last = 0x30,
- },
- {
- .first = 0x40,
- .last = 0x48,
- },
- /* 0x80-0x8B is SIM registers and should
- * not be accessed from here */
- },
- },
- [AB8500_USB] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x80,
- .last = 0x83,
- },
- {
- .first = 0x87,
- .last = 0x8A,
- },
- {
- .first = 0x91,
- .last = 0x94,
- },
- },
- },
- [AB8500_TVOUT] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_DBI] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_ECI_AV_ACC] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x80,
- .last = 0x82,
- },
- },
- },
- [AB8500_RESERVED] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_GPADC] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x08,
- },
- },
- },
- [AB8500_CHARGER] = {
- .num_ranges = 9,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x02,
- .last = 0x03,
- },
- {
- .first = 0x05,
- .last = 0x05,
- },
- {
- .first = 0x40,
- .last = 0x44,
- },
- {
- .first = 0x50,
- .last = 0x57,
- },
- {
- .first = 0x60,
- .last = 0x60,
- },
- {
- .first = 0xA0,
- .last = 0xA7,
- },
- {
- .first = 0xAF,
- .last = 0xB2,
- },
- {
- .first = 0xC0,
- .last = 0xC2,
- },
- {
- .first = 0xF5,
- .last = 0xF5,
- },
- },
- },
- [AB8500_GAS_GAUGE] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x07,
- .last = 0x0A,
- },
- {
- .first = 0x10,
- .last = 0x14,
- },
- },
- },
- [AB8500_AUDIO] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x83,
- },
- },
- },
- [AB8500_INTERRUPT] = {
- .num_ranges = 11,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x04,
- },
- {
- .first = 0x06,
- .last = 0x07,
- },
- {
- .first = 0x09,
- .last = 0x09,
- },
- {
- .first = 0x0B,
- .last = 0x0C,
- },
- {
- .first = 0x12,
- .last = 0x15,
- },
- {
- .first = 0x18,
- .last = 0x18,
- },
- /* Latch registers should not be read here */
- {
- .first = 0x40,
- .last = 0x44,
- },
- {
- .first = 0x46,
- .last = 0x49,
- },
- {
- .first = 0x4B,
- .last = 0x4D,
- },
- {
- .first = 0x52,
- .last = 0x55,
- },
- {
- .first = 0x58,
- .last = 0x58,
- },
- /* LatchHier registers should not be read here */
- },
- },
- [AB8500_RTC] = {
- .num_ranges = 2,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x14,
- },
- {
- .first = 0x16,
- .last = 0x17,
- },
- },
- },
- [AB8500_MISC] = {
- .num_ranges = 8,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x06,
- },
- {
- .first = 0x10,
- .last = 0x16,
- },
- {
- .first = 0x20,
- .last = 0x26,
- },
- {
- .first = 0x30,
- .last = 0x36,
- },
- {
- .first = 0x40,
- .last = 0x46,
- },
- {
- .first = 0x50,
- .last = 0x50,
- },
- {
- .first = 0x60,
- .last = 0x6B,
- },
- {
- .first = 0x80,
- .last = 0x82,
- },
- },
- },
- [AB8500_DEVELOPMENT] = {
- .num_ranges = 2,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x05,
- .last = 0x05,
- },
- },
- },
- [AB8500_DEBUG] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x05,
- .last = 0x07,
- },
- },
- },
- [AB8500_PROD_TEST] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_STE_TEST] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_OTP_EMUL] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x01,
- .last = 0x15,
- },
- },
- },
- };
- static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = {
- [AB8500_M_FSM_RANK] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x0B,
- },
- },
- },
- [AB8500_SYS_CTRL1_BLOCK] = {
- .num_ranges = 6,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x04,
- },
- {
- .first = 0x42,
- .last = 0x42,
- },
- {
- .first = 0x50,
- .last = 0x54,
- },
- {
- .first = 0x57,
- .last = 0x57,
- },
- {
- .first = 0x80,
- .last = 0x83,
- },
- {
- .first = 0x90,
- .last = 0x90,
- },
- },
- },
- [AB8500_SYS_CTRL2_BLOCK] = {
- .num_ranges = 5,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x0D,
- },
- {
- .first = 0x0F,
- .last = 0x10,
- },
- {
- .first = 0x20,
- .last = 0x21,
- },
- {
- .first = 0x32,
- .last = 0x3C,
- },
- {
- .first = 0x40,
- .last = 0x42,
- },
- },
- },
- [AB8500_REGU_CTRL1] = {
- .num_ranges = 4,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x03,
- .last = 0x15,
- },
- {
- .first = 0x20,
- .last = 0x20,
- },
- {
- .first = 0x80,
- .last = 0x85,
- },
- {
- .first = 0x87,
- .last = 0x88,
- },
- },
- },
- [AB8500_REGU_CTRL2] = {
- .num_ranges = 8,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x06,
- },
- {
- .first = 0x08,
- .last = 0x15,
- },
- {
- .first = 0x17,
- .last = 0x19,
- },
- {
- .first = 0x1B,
- .last = 0x1D,
- },
- {
- .first = 0x1F,
- .last = 0x2F,
- },
- {
- .first = 0x31,
- .last = 0x3A,
- },
- {
- .first = 0x43,
- .last = 0x44,
- },
- {
- .first = 0x48,
- .last = 0x49,
- },
- },
- },
- [AB8500_USB] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x80,
- .last = 0x83,
- },
- {
- .first = 0x87,
- .last = 0x8A,
- },
- {
- .first = 0x91,
- .last = 0x94,
- },
- },
- },
- [AB8500_TVOUT] = {
- .num_ranges = 0,
- .range = NULL
- },
- [AB8500_DBI] = {
- .num_ranges = 4,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x07,
- },
- {
- .first = 0x10,
- .last = 0x11,
- },
- {
- .first = 0x20,
- .last = 0x21,
- },
- {
- .first = 0x30,
- .last = 0x43,
- },
- },
- },
- [AB8500_ECI_AV_ACC] = {
- .num_ranges = 2,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x03,
- },
- {
- .first = 0x80,
- .last = 0x82,
- },
- },
- },
- [AB8500_RESERVED] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_GPADC] = {
- .num_ranges = 4,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x01,
- },
- {
- .first = 0x04,
- .last = 0x06,
- },
- {
- .first = 0x09,
- .last = 0x0A,
- },
- {
- .first = 0x10,
- .last = 0x14,
- },
- },
- },
- [AB8500_CHARGER] = {
- .num_ranges = 10,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x02,
- .last = 0x05,
- },
- {
- .first = 0x40,
- .last = 0x44,
- },
- {
- .first = 0x50,
- .last = 0x57,
- },
- {
- .first = 0x60,
- .last = 0x60,
- },
- {
- .first = 0x70,
- .last = 0x70,
- },
- {
- .first = 0xA0,
- .last = 0xA9,
- },
- {
- .first = 0xAF,
- .last = 0xB2,
- },
- {
- .first = 0xC0,
- .last = 0xC6,
- },
- {
- .first = 0xF5,
- .last = 0xF5,
- },
- },
- },
- [AB8500_GAS_GAUGE] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x00,
- },
- {
- .first = 0x07,
- .last = 0x0A,
- },
- {
- .first = 0x10,
- .last = 0x14,
- },
- },
- },
- [AB8500_AUDIO] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x9f,
- },
- },
- },
- [AB8500_INTERRUPT] = {
- .num_ranges = 6,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x05,
- },
- {
- .first = 0x0B,
- .last = 0x0D,
- },
- {
- .first = 0x12,
- .last = 0x20,
- },
- /* Latch registers should not be read here */
- {
- .first = 0x40,
- .last = 0x45,
- },
- {
- .first = 0x4B,
- .last = 0x4D,
- },
- {
- .first = 0x52,
- .last = 0x60,
- },
- /* LatchHier registers should not be read here */
- },
- },
- [AB8500_RTC] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x07,
- },
- {
- .first = 0x0B,
- .last = 0x18,
- },
- {
- .first = 0x20,
- .last = 0x25,
- },
- },
- },
- [AB8500_MISC] = {
- .num_ranges = 9,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x06,
- },
- {
- .first = 0x10,
- .last = 0x16,
- },
- {
- .first = 0x20,
- .last = 0x26,
- },
- {
- .first = 0x30,
- .last = 0x36,
- },
- {
- .first = 0x40,
- .last = 0x49,
- },
- {
- .first = 0x50,
- .last = 0x50,
- },
- {
- .first = 0x60,
- .last = 0x6B,
- },
- {
- .first = 0x70,
- .last = 0x74,
- },
- {
- .first = 0x80,
- .last = 0x82,
- },
- },
- },
- [AB8500_DEVELOPMENT] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x01,
- },
- {
- .first = 0x06,
- .last = 0x06,
- },
- {
- .first = 0x10,
- .last = 0x21,
- },
- },
- },
- [AB8500_DEBUG] = {
- .num_ranges = 3,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x01,
- .last = 0x0C,
- },
- {
- .first = 0x0E,
- .last = 0x11,
- },
- {
- .first = 0x80,
- .last = 0x81,
- },
- },
- },
- [AB8500_PROD_TEST] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_STE_TEST] = {
- .num_ranges = 0,
- .range = NULL,
- },
- [AB8500_OTP_EMUL] = {
- .num_ranges = 1,
- .range = (struct ab8500_reg_range[]) {
- {
- .first = 0x00,
- .last = 0x3F,
- },
- },
- },
- };
- static irqreturn_t ab8500_debug_handler(int irq, void *data)
- {
- char buf[16];
- struct kobject *kobj = (struct kobject *)data;
- unsigned int irq_abb = irq - irq_first;
- if (irq_abb < num_irqs)
- irq_count[irq_abb]++;
- /*
- * This makes it possible to use poll for events (POLLPRI | POLLERR)
- * from userspace on sysfs file named <irq-nr>
- */
- sprintf(buf, "%d", irq);
- sysfs_notify(kobj, NULL, buf);
- return IRQ_HANDLED;
- }
- /* Prints to seq_file or log_buf */
- static int ab8500_registers_print(struct device *dev, u32 bank,
- struct seq_file *s)
- {
- unsigned int i;
- for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
- u32 reg;
- for (reg = debug_ranges[bank].range[i].first;
- reg <= debug_ranges[bank].range[i].last;
- reg++) {
- u8 value;
- int err;
- err = abx500_get_register_interruptible(dev,
- (u8)bank, (u8)reg, &value);
- if (err < 0) {
- dev_err(dev, "ab->read fail %d\n", err);
- return err;
- }
- if (s) {
- seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n",
- bank, reg, value);
- /* Error is not returned here since
- * the output is wanted in any case */
- if (seq_has_overflowed(s))
- return 0;
- } else {
- dev_info(dev, " [0x%02X/0x%02X]: 0x%02X\n",
- bank, reg, value);
- }
- }
- }
- return 0;
- }
- static int ab8500_print_bank_registers(struct seq_file *s, void *p)
- {
- struct device *dev = s->private;
- u32 bank = debug_bank;
- seq_puts(s, AB8500_NAME_STRING " register values:\n");
- seq_printf(s, " bank 0x%02X:\n", bank);
- return ab8500_registers_print(dev, bank, s);
- }
- static int ab8500_registers_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_print_bank_registers, inode->i_private);
- }
- static const struct file_operations ab8500_registers_fops = {
- .open = ab8500_registers_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_print_all_banks(struct seq_file *s, void *p)
- {
- struct device *dev = s->private;
- unsigned int i;
- seq_puts(s, AB8500_NAME_STRING " register values:\n");
- for (i = 0; i < AB8500_NUM_BANKS; i++) {
- int err;
- seq_printf(s, " bank 0x%02X:\n", i);
- err = ab8500_registers_print(dev, i, s);
- if (err)
- return err;
- }
- return 0;
- }
- /* Dump registers to kernel log */
- void ab8500_dump_all_banks(struct device *dev)
- {
- unsigned int i;
- dev_info(dev, "ab8500 register values:\n");
- for (i = 1; i < AB8500_NUM_BANKS; i++) {
- dev_info(dev, " bank 0x%02X:\n", i);
- ab8500_registers_print(dev, i, NULL);
- }
- }
- /* Space for 500 registers. */
- #define DUMP_MAX_REGS 700
- static struct ab8500_register_dump
- {
- u8 bank;
- u8 reg;
- u8 value;
- } ab8500_complete_register_dump[DUMP_MAX_REGS];
- /* This shall only be called upon kernel panic! */
- void ab8500_dump_all_banks_to_mem(void)
- {
- int i, r = 0;
- u8 bank;
- int err = 0;
- pr_info("Saving all ABB registers for crash analysis.\n");
- for (bank = 0; bank < AB8500_NUM_BANKS; bank++) {
- for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
- u8 reg;
- for (reg = debug_ranges[bank].range[i].first;
- reg <= debug_ranges[bank].range[i].last;
- reg++) {
- u8 value;
- err = prcmu_abb_read(bank, reg, &value, 1);
- if (err < 0)
- goto out;
- ab8500_complete_register_dump[r].bank = bank;
- ab8500_complete_register_dump[r].reg = reg;
- ab8500_complete_register_dump[r].value = value;
- r++;
- if (r >= DUMP_MAX_REGS) {
- pr_err("%s: too many register to dump!\n",
- __func__);
- err = -EINVAL;
- goto out;
- }
- }
- }
- }
- out:
- if (err >= 0)
- pr_info("Saved all ABB registers.\n");
- else
- pr_info("Failed to save all ABB registers.\n");
- }
- static int ab8500_all_banks_open(struct inode *inode, struct file *file)
- {
- struct seq_file *s;
- int err;
- err = single_open(file, ab8500_print_all_banks, inode->i_private);
- if (!err) {
- /* Default buf size in seq_read is not enough */
- s = (struct seq_file *)file->private_data;
- s->size = (PAGE_SIZE * 2);
- s->buf = kmalloc(s->size, GFP_KERNEL);
- if (!s->buf) {
- single_release(inode, file);
- err = -ENOMEM;
- }
- }
- return err;
- }
- static const struct file_operations ab8500_all_banks_fops = {
- .open = ab8500_all_banks_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_bank_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "0x%02X\n", debug_bank);
- return 0;
- }
- static int ab8500_bank_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_bank_print, inode->i_private);
- }
- static ssize_t ab8500_bank_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_bank;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
- if (err)
- return err;
- if (user_bank >= AB8500_NUM_BANKS) {
- dev_err(dev, "debugfs error input > number of banks\n");
- return -EINVAL;
- }
- debug_bank = user_bank;
- return count;
- }
- static int ab8500_address_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "0x%02X\n", debug_address);
- return 0;
- }
- static int ab8500_address_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_address_print, inode->i_private);
- }
- static ssize_t ab8500_address_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_address;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_address);
- if (err)
- return err;
- if (user_address > 0xff) {
- dev_err(dev, "debugfs error input > 0xff\n");
- return -EINVAL;
- }
- debug_address = user_address;
- return count;
- }
- static int ab8500_val_print(struct seq_file *s, void *p)
- {
- struct device *dev = s->private;
- int ret;
- u8 regvalue;
- ret = abx500_get_register_interruptible(dev,
- (u8)debug_bank, (u8)debug_address, ®value);
- if (ret < 0) {
- dev_err(dev, "abx500_get_reg fail %d, %d\n",
- ret, __LINE__);
- return -EINVAL;
- }
- seq_printf(s, "0x%02X\n", regvalue);
- return 0;
- }
- static int ab8500_val_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_val_print, inode->i_private);
- }
- static ssize_t ab8500_val_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_val;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_val);
- if (err)
- return err;
- if (user_val > 0xff) {
- dev_err(dev, "debugfs error input > 0xff\n");
- return -EINVAL;
- }
- err = abx500_set_register_interruptible(dev,
- (u8)debug_bank, debug_address, (u8)user_val);
- if (err < 0) {
- pr_err("abx500_set_reg failed %d, %d", err, __LINE__);
- return -EINVAL;
- }
- return count;
- }
- /*
- * Interrupt status
- */
- static u32 num_interrupts[AB8500_MAX_NR_IRQS];
- static u32 num_wake_interrupts[AB8500_MAX_NR_IRQS];
- static int num_interrupt_lines;
- bool __attribute__((weak)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int)
- {
- return false;
- }
- void ab8500_debug_register_interrupt(int line)
- {
- if (line < num_interrupt_lines) {
- num_interrupts[line]++;
- if (suspend_test_wake_cause_interrupt_is_mine(irq_ab8500))
- num_wake_interrupts[line]++;
- }
- }
- static int ab8500_interrupts_print(struct seq_file *s, void *p)
- {
- int line;
- seq_puts(s, "name: number: number of: wake:\n");
- for (line = 0; line < num_interrupt_lines; line++) {
- struct irq_desc *desc = irq_to_desc(line + irq_first);
- seq_printf(s, "%3i: %6i %4i",
- line,
- num_interrupts[line],
- num_wake_interrupts[line]);
- if (desc && desc->name)
- seq_printf(s, "-%-8s", desc->name);
- if (desc && desc->action) {
- struct irqaction *action = desc->action;
- seq_printf(s, " %s", action->name);
- while ((action = action->next) != NULL)
- seq_printf(s, ", %s", action->name);
- }
- seq_putc(s, '\n');
- }
- return 0;
- }
- static int ab8500_interrupts_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_interrupts_print, inode->i_private);
- }
- /*
- * - HWREG DB8500 formated routines
- */
- static int ab8500_hwreg_print(struct seq_file *s, void *d)
- {
- struct device *dev = s->private;
- int ret;
- u8 regvalue;
- ret = abx500_get_register_interruptible(dev,
- (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value);
- if (ret < 0) {
- dev_err(dev, "abx500_get_reg fail %d, %d\n",
- ret, __LINE__);
- return -EINVAL;
- }
- if (hwreg_cfg.shift >= 0)
- regvalue >>= hwreg_cfg.shift;
- else
- regvalue <<= -hwreg_cfg.shift;
- regvalue &= hwreg_cfg.mask;
- if (REG_FMT_DEC(&hwreg_cfg))
- seq_printf(s, "%d\n", regvalue);
- else
- seq_printf(s, "0x%02X\n", regvalue);
- return 0;
- }
- static int ab8500_hwreg_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_hwreg_print, inode->i_private);
- }
- #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01
- #define AB8500_SUPPLY_CONTROL_REG 0x00
- #define AB8500_FIRST_SIM_REG 0x80
- #define AB8500_LAST_SIM_REG 0x8B
- #define AB8505_LAST_SIM_REG 0x8C
- static int ab8500_print_modem_registers(struct seq_file *s, void *p)
- {
- struct device *dev = s->private;
- struct ab8500 *ab8500;
- int err;
- u8 value;
- u8 orig_value;
- u32 bank = AB8500_REGU_CTRL2;
- u32 last_sim_reg = AB8500_LAST_SIM_REG;
- u32 reg;
- ab8500 = dev_get_drvdata(dev->parent);
- dev_warn(dev, "WARNING! This operation can interfer with modem side\n"
- "and should only be done with care\n");
- err = abx500_get_register_interruptible(dev,
- AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value);
- if (err < 0) {
- dev_err(dev, "ab->read fail %d\n", err);
- return err;
- }
- /* Config 1 will allow APE side to read SIM registers */
- err = abx500_set_register_interruptible(dev,
- AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG,
- AB8500_SUPPLY_CONTROL_CONFIG_1);
- if (err < 0) {
- dev_err(dev, "ab->write fail %d\n", err);
- return err;
- }
- seq_printf(s, " bank 0x%02X:\n", bank);
- if (is_ab9540(ab8500) || is_ab8505(ab8500))
- last_sim_reg = AB8505_LAST_SIM_REG;
- for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) {
- err = abx500_get_register_interruptible(dev,
- bank, reg, &value);
- if (err < 0) {
- dev_err(dev, "ab->read fail %d\n", err);
- return err;
- }
- seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", bank, reg, value);
- }
- err = abx500_set_register_interruptible(dev,
- AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value);
- if (err < 0) {
- dev_err(dev, "ab->write fail %d\n", err);
- return err;
- }
- return 0;
- }
- static int ab8500_modem_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_print_modem_registers,
- inode->i_private);
- }
- static const struct file_operations ab8500_modem_fops = {
- .open = ab8500_modem_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
- {
- int bat_ctrl_raw;
- int bat_ctrl_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
- avg_sample, trig_edge, trig_timer, conv_type);
- bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- BAT_CTRL, bat_ctrl_raw);
- seq_printf(s, "%d,0x%X\n", bat_ctrl_convert, bat_ctrl_raw);
- return 0;
- }
- static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_bat_ctrl_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_bat_ctrl_fops = {
- .open = ab8500_gpadc_bat_ctrl_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
- {
- int btemp_ball_raw;
- int btemp_ball_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
- avg_sample, trig_edge, trig_timer, conv_type);
- btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
- btemp_ball_raw);
- seq_printf(s, "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
- return 0;
- }
- static int ab8500_gpadc_btemp_ball_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_btemp_ball_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_btemp_ball_fops = {
- .open = ab8500_gpadc_btemp_ball_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
- {
- int main_charger_v_raw;
- int main_charger_v_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
- avg_sample, trig_edge, trig_timer, conv_type);
- main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- MAIN_CHARGER_V, main_charger_v_raw);
- seq_printf(s, "%d,0x%X\n", main_charger_v_convert, main_charger_v_raw);
- return 0;
- }
- static int ab8500_gpadc_main_charger_v_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_main_charger_v_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_main_charger_v_fops = {
- .open = ab8500_gpadc_main_charger_v_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
- {
- int acc_detect1_raw;
- int acc_detect1_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
- avg_sample, trig_edge, trig_timer, conv_type);
- acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
- acc_detect1_raw);
- seq_printf(s, "%d,0x%X\n", acc_detect1_convert, acc_detect1_raw);
- return 0;
- }
- static int ab8500_gpadc_acc_detect1_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_acc_detect1_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_acc_detect1_fops = {
- .open = ab8500_gpadc_acc_detect1_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
- {
- int acc_detect2_raw;
- int acc_detect2_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
- avg_sample, trig_edge, trig_timer, conv_type);
- acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- ACC_DETECT2, acc_detect2_raw);
- seq_printf(s, "%d,0x%X\n", acc_detect2_convert, acc_detect2_raw);
- return 0;
- }
- static int ab8500_gpadc_acc_detect2_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_acc_detect2_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_acc_detect2_fops = {
- .open = ab8500_gpadc_acc_detect2_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
- {
- int aux1_raw;
- int aux1_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
- avg_sample, trig_edge, trig_timer, conv_type);
- aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
- aux1_raw);
- seq_printf(s, "%d,0x%X\n", aux1_convert, aux1_raw);
- return 0;
- }
- static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_aux1_print, inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_aux1_fops = {
- .open = ab8500_gpadc_aux1_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
- {
- int aux2_raw;
- int aux2_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
- avg_sample, trig_edge, trig_timer, conv_type);
- aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
- aux2_raw);
- seq_printf(s, "%d,0x%X\n", aux2_convert, aux2_raw);
- return 0;
- }
- static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_aux2_print, inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_aux2_fops = {
- .open = ab8500_gpadc_aux2_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
- {
- int main_bat_v_raw;
- int main_bat_v_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
- avg_sample, trig_edge, trig_timer, conv_type);
- main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
- main_bat_v_raw);
- seq_printf(s, "%d,0x%X\n", main_bat_v_convert, main_bat_v_raw);
- return 0;
- }
- static int ab8500_gpadc_main_bat_v_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_main_bat_v_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_main_bat_v_fops = {
- .open = ab8500_gpadc_main_bat_v_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
- {
- int vbus_v_raw;
- int vbus_v_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
- avg_sample, trig_edge, trig_timer, conv_type);
- vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
- vbus_v_raw);
- seq_printf(s, "%d,0x%X\n", vbus_v_convert, vbus_v_raw);
- return 0;
- }
- static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_vbus_v_fops = {
- .open = ab8500_gpadc_vbus_v_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
- {
- int main_charger_c_raw;
- int main_charger_c_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
- avg_sample, trig_edge, trig_timer, conv_type);
- main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- MAIN_CHARGER_C, main_charger_c_raw);
- seq_printf(s, "%d,0x%X\n", main_charger_c_convert, main_charger_c_raw);
- return 0;
- }
- static int ab8500_gpadc_main_charger_c_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_main_charger_c_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_main_charger_c_fops = {
- .open = ab8500_gpadc_main_charger_c_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
- {
- int usb_charger_c_raw;
- int usb_charger_c_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
- avg_sample, trig_edge, trig_timer, conv_type);
- usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- USB_CHARGER_C, usb_charger_c_raw);
- seq_printf(s, "%d,0x%X\n", usb_charger_c_convert, usb_charger_c_raw);
- return 0;
- }
- static int ab8500_gpadc_usb_charger_c_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_gpadc_usb_charger_c_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_usb_charger_c_fops = {
- .open = ab8500_gpadc_usb_charger_c_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
- {
- int bk_bat_v_raw;
- int bk_bat_v_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
- avg_sample, trig_edge, trig_timer, conv_type);
- bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- BK_BAT_V, bk_bat_v_raw);
- seq_printf(s, "%d,0x%X\n", bk_bat_v_convert, bk_bat_v_raw);
- return 0;
- }
- static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_bk_bat_v_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_bk_bat_v_fops = {
- .open = ab8500_gpadc_bk_bat_v_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
- {
- int die_temp_raw;
- int die_temp_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
- avg_sample, trig_edge, trig_timer, conv_type);
- die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
- die_temp_raw);
- seq_printf(s, "%d,0x%X\n", die_temp_convert, die_temp_raw);
- return 0;
- }
- static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_die_temp_print,
- inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_die_temp_fops = {
- .open = ab8500_gpadc_die_temp_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_usb_id_print(struct seq_file *s, void *p)
- {
- int usb_id_raw;
- int usb_id_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID,
- avg_sample, trig_edge, trig_timer, conv_type);
- usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID,
- usb_id_raw);
- seq_printf(s, "%d,0x%X\n", usb_id_convert, usb_id_raw);
- return 0;
- }
- static int ab8500_gpadc_usb_id_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_usb_id_print, inode->i_private);
- }
- static const struct file_operations ab8500_gpadc_usb_id_fops = {
- .open = ab8500_gpadc_usb_id_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_xtal_temp_print(struct seq_file *s, void *p)
- {
- int xtal_temp_raw;
- int xtal_temp_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP,
- avg_sample, trig_edge, trig_timer, conv_type);
- xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP,
- xtal_temp_raw);
- seq_printf(s, "%d,0x%X\n", xtal_temp_convert, xtal_temp_raw);
- return 0;
- }
- static int ab8540_gpadc_xtal_temp_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8540_gpadc_xtal_temp_print,
- inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_xtal_temp_fops = {
- .open = ab8540_gpadc_xtal_temp_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_vbat_true_meas_print(struct seq_file *s, void *p)
- {
- int vbat_true_meas_raw;
- int vbat_true_meas_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS,
- avg_sample, trig_edge, trig_timer, conv_type);
- vbat_true_meas_convert =
- ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS,
- vbat_true_meas_raw);
- seq_printf(s, "%d,0x%X\n", vbat_true_meas_convert, vbat_true_meas_raw);
- return 0;
- }
- static int ab8540_gpadc_vbat_true_meas_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8540_gpadc_vbat_true_meas_print,
- inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_vbat_true_meas_fops = {
- .open = ab8540_gpadc_vbat_true_meas_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file *s, void *p)
- {
- int bat_ctrl_raw;
- int bat_ctrl_convert;
- int ibat_raw;
- int ibat_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT,
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
- bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL,
- bat_ctrl_raw);
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
- ibat_raw);
- seq_printf(s,
- "%d,0x%X\n"
- "%d,0x%X\n",
- bat_ctrl_convert, bat_ctrl_raw,
- ibat_convert, ibat_raw);
- return 0;
- }
- static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8540_gpadc_bat_ctrl_and_ibat_print,
- inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops = {
- .open = ab8540_gpadc_bat_ctrl_and_ibat_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file *s, void *p)
- {
- int vbat_meas_raw;
- int vbat_meas_convert;
- int ibat_raw;
- int ibat_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT,
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
- vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
- vbat_meas_raw);
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
- ibat_raw);
- seq_printf(s,
- "%d,0x%X\n"
- "%d,0x%X\n",
- vbat_meas_convert, vbat_meas_raw,
- ibat_convert, ibat_raw);
- return 0;
- }
- static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8540_gpadc_vbat_meas_and_ibat_print,
- inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops = {
- .open = ab8540_gpadc_vbat_meas_and_ibat_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file *s,
- void *p)
- {
- int vbat_true_meas_raw;
- int vbat_true_meas_convert;
- int ibat_raw;
- int ibat_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc,
- VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge,
- trig_timer, conv_type, &ibat_raw);
- vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc,
- VBAT_TRUE_MEAS, vbat_true_meas_raw);
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
- ibat_raw);
- seq_printf(s,
- "%d,0x%X\n"
- "%d,0x%X\n",
- vbat_true_meas_convert, vbat_true_meas_raw,
- ibat_convert, ibat_raw);
- return 0;
- }
- static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8540_gpadc_vbat_true_meas_and_ibat_print,
- inode->i_private);
- }
- static const struct file_operations
- ab8540_gpadc_vbat_true_meas_and_ibat_fops = {
- .open = ab8540_gpadc_vbat_true_meas_and_ibat_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file *s, void *p)
- {
- int bat_temp_raw;
- int bat_temp_convert;
- int ibat_raw;
- int ibat_convert;
- struct ab8500_gpadc *gpadc;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT,
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
- bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
- bat_temp_raw);
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
- ibat_raw);
- seq_printf(s,
- "%d,0x%X\n"
- "%d,0x%X\n",
- bat_temp_convert, bat_temp_raw,
- ibat_convert, ibat_raw);
- return 0;
- }
- static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8540_gpadc_bat_temp_and_ibat_print,
- inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops = {
- .open = ab8540_gpadc_bat_temp_and_ibat_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8540_gpadc_otp_cal_print(struct seq_file *s, void *p)
- {
- struct ab8500_gpadc *gpadc;
- u16 vmain_l, vmain_h, btemp_l, btemp_h;
- u16 vbat_l, vbat_h, ibat_l, ibat_h;
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
- ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h,
- &vbat_l, &vbat_h, &ibat_l, &ibat_h);
- seq_printf(s,
- "VMAIN_L:0x%X\n"
- "VMAIN_H:0x%X\n"
- "BTEMP_L:0x%X\n"
- "BTEMP_H:0x%X\n"
- "VBAT_L:0x%X\n"
- "VBAT_H:0x%X\n"
- "IBAT_L:0x%X\n"
- "IBAT_H:0x%X\n",
- vmain_l, vmain_h, btemp_l, btemp_h,
- vbat_l, vbat_h, ibat_l, ibat_h);
- return 0;
- }
- static int ab8540_gpadc_otp_cal_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8540_gpadc_otp_cal_print, inode->i_private);
- }
- static const struct file_operations ab8540_gpadc_otp_calib_fops = {
- .open = ab8540_gpadc_otp_cal_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "%d\n", avg_sample);
- return 0;
- }
- static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_avg_sample_print,
- inode->i_private);
- }
- static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_avg_sample;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample);
- if (err)
- return err;
- if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
- || (user_avg_sample == SAMPLE_8)
- || (user_avg_sample == SAMPLE_16)) {
- avg_sample = (u8) user_avg_sample;
- } else {
- dev_err(dev,
- "debugfs err input: should be egal to 1, 4, 8 or 16\n");
- return -EINVAL;
- }
- return count;
- }
- static const struct file_operations ab8500_gpadc_avg_sample_fops = {
- .open = ab8500_gpadc_avg_sample_open,
- .read = seq_read,
- .write = ab8500_gpadc_avg_sample_write,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "%d\n", trig_edge);
- return 0;
- }
- static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_trig_edge_print,
- inode->i_private);
- }
- static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_trig_edge;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge);
- if (err)
- return err;
- if ((user_trig_edge == RISING_EDGE)
- || (user_trig_edge == FALLING_EDGE)) {
- trig_edge = (u8) user_trig_edge;
- } else {
- dev_err(dev, "Wrong input:\n"
- "Enter 0. Rising edge\n"
- "Enter 1. Falling edge\n");
- return -EINVAL;
- }
- return count;
- }
- static const struct file_operations ab8500_gpadc_trig_edge_fops = {
- .open = ab8500_gpadc_trig_edge_open,
- .read = seq_read,
- .write = ab8500_gpadc_trig_edge_write,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "%d\n", trig_timer);
- return 0;
- }
- static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_trig_timer_print,
- inode->i_private);
- }
- static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_trig_timer;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer);
- if (err)
- return err;
- if (user_trig_timer & ~0xFF) {
- dev_err(dev,
- "debugfs error input: should be beetween 0 to 255\n");
- return -EINVAL;
- }
- trig_timer = (u8) user_trig_timer;
- return count;
- }
- static const struct file_operations ab8500_gpadc_trig_timer_fops = {
- .open = ab8500_gpadc_trig_timer_open,
- .read = seq_read,
- .write = ab8500_gpadc_trig_timer_write,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "%d\n", conv_type);
- return 0;
- }
- static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
- {
- return single_open(file, ab8500_gpadc_conv_type_print,
- inode->i_private);
- }
- static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_conv_type;
- int err;
- err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type);
- if (err)
- return err;
- if ((user_conv_type == ADC_SW)
- || (user_conv_type == ADC_HW)) {
- conv_type = (u8) user_conv_type;
- } else {
- dev_err(dev, "Wrong input:\n"
- "Enter 0. ADC SW conversion\n"
- "Enter 1. ADC HW conversion\n");
- return -EINVAL;
- }
- return count;
- }
- static const struct file_operations ab8500_gpadc_conv_type_fops = {
- .open = ab8500_gpadc_conv_type_open,
- .read = seq_read,
- .write = ab8500_gpadc_conv_type_write,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- /*
- * return length of an ASCII numerical value, 0 is string is not a
- * numerical value.
- * string shall start at value 1st char.
- * string can be tailed with \0 or space or newline chars only.
- * value can be decimal or hexadecimal (prefixed 0x or 0X).
- */
- static int strval_len(char *b)
- {
- char *s = b;
- if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) {
- s += 2;
- for (; *s && (*s != ' ') && (*s != '\n'); s++) {
- if (!isxdigit(*s))
- return 0;
- }
- } else {
- if (*s == '-')
- s++;
- for (; *s && (*s != ' ') && (*s != '\n'); s++) {
- if (!isdigit(*s))
- return 0;
- }
- }
- return (int) (s-b);
- }
- /*
- * parse hwreg input data.
- * update global hwreg_cfg only if input data syntax is ok.
- */
- static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
- struct device *dev)
- {
- uint write, val = 0;
- u8 regvalue;
- int ret;
- struct hwreg_cfg loc = {
- .bank = 0, /* default: invalid phys addr */
- .addr = 0, /* default: invalid phys addr */
- .fmt = 0, /* default: 32bit access, hex output */
- .mask = 0xFFFFFFFF, /* default: no mask */
- .shift = 0, /* default: no bit shift */
- };
- /* read or write ? */
- if (!strncmp(b, "read ", 5)) {
- write = 0;
- b += 5;
- } else if (!strncmp(b, "write ", 6)) {
- write = 1;
- b += 6;
- } else
- return -EINVAL;
- /* OPTIONS -l|-w|-b -s -m -o */
- while ((*b == ' ') || (*b == '-')) {
- if (*(b-1) != ' ') {
- b++;
- continue;
- }
- if ((!strncmp(b, "-d ", 3)) ||
- (!strncmp(b, "-dec ", 5))) {
- b += (*(b+2) == ' ') ? 3 : 5;
- loc.fmt |= (1<<0);
- } else if ((!strncmp(b, "-h ", 3)) ||
- (!strncmp(b, "-hex ", 5))) {
- b += (*(b+2) == ' ') ? 3 : 5;
- loc.fmt &= ~(1<<0);
- } else if ((!strncmp(b, "-m ", 3)) ||
- (!strncmp(b, "-mask ", 6))) {
- b += (*(b+2) == ' ') ? 3 : 6;
- if (strval_len(b) == 0)
- return -EINVAL;
- ret = kstrtoul(b, 0, &loc.mask);
- if (ret)
- return ret;
- } else if ((!strncmp(b, "-s ", 3)) ||
- (!strncmp(b, "-shift ", 7))) {
- b += (*(b+2) == ' ') ? 3 : 7;
- if (strval_len(b) == 0)
- return -EINVAL;
- ret = kstrtol(b, 0, &loc.shift);
- if (ret)
- return ret;
- } else {
- return -EINVAL;
- }
- }
- /* get arg BANK and ADDRESS */
- if (strval_len(b) == 0)
- return -EINVAL;
- ret = kstrtouint(b, 0, &loc.bank);
- if (ret)
- return ret;
- while (*b == ' ')
- b++;
- if (strval_len(b) == 0)
- return -EINVAL;
- ret = kstrtoul(b, 0, &loc.addr);
- if (ret)
- return ret;
- if (write) {
- while (*b == ' ')
- b++;
- if (strval_len(b) == 0)
- return -EINVAL;
- ret = kstrtouint(b, 0, &val);
- if (ret)
- return ret;
- }
- /* args are ok, update target cfg (mainly for read) */
- *cfg = loc;
- #ifdef ABB_HWREG_DEBUG
- pr_warn("HWREG request: %s, %s,\n"
- " addr=0x%08X, mask=0x%X, shift=%d" "value=0x%X\n",
- (write) ? "write" : "read",
- REG_FMT_DEC(cfg) ? "decimal" : "hexa",
- cfg->addr, cfg->mask, cfg->shift, val);
- #endif
- if (!write)
- return 0;
- ret = abx500_get_register_interruptible(dev,
- (u8)cfg->bank, (u8)cfg->addr, ®value);
- if (ret < 0) {
- dev_err(dev, "abx500_get_reg fail %d, %d\n",
- ret, __LINE__);
- return -EINVAL;
- }
- if (cfg->shift >= 0) {
- regvalue &= ~(cfg->mask << (cfg->shift));
- val = (val & cfg->mask) << (cfg->shift);
- } else {
- regvalue &= ~(cfg->mask >> (-cfg->shift));
- val = (val & cfg->mask) >> (-cfg->shift);
- }
- val = val | regvalue;
- ret = abx500_set_register_interruptible(dev,
- (u8)cfg->bank, (u8)cfg->addr, (u8)val);
- if (ret < 0) {
- pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
- return -EINVAL;
- }
- return 0;
- }
- static ssize_t ab8500_hwreg_write(struct file *file,
- const char __user *user_buf, size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- char buf[128];
- int buf_size, ret;
- /* Get userspace string and assure termination */
- buf_size = min(count, (sizeof(buf)-1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
- buf[buf_size] = 0;
- /* get args and process */
- ret = hwreg_common_write(buf, &hwreg_cfg, dev);
- return (ret) ? ret : buf_size;
- }
- /*
- * - irq subscribe/unsubscribe stuff
- */
- static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
- {
- seq_printf(s, "%d\n", irq_first);
- return 0;
- }
- static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
- struct file *file)
- {
- return single_open(file, ab8500_subscribe_unsubscribe_print,
- inode->i_private);
- }
- /*
- * Userspace should use poll() on this file. When an event occur
- * the blocking poll will be released.
- */
- static ssize_t show_irq(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- unsigned long name;
- unsigned int irq_index;
- int err;
- err = kstrtoul(attr->attr.name, 0, &name);
- if (err)
- return err;
- irq_index = name - irq_first;
- if (irq_index >= num_irqs)
- return -EINVAL;
- return sprintf(buf, "%u\n", irq_count[irq_index]);
- }
- static ssize_t ab8500_subscribe_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_val;
- int err;
- unsigned int irq_index;
- err = kstrtoul_from_user(user_buf, count, 0, &user_val);
- if (err)
- return err;
- if (user_val < irq_first) {
- dev_err(dev, "debugfs error input < %d\n", irq_first);
- return -EINVAL;
- }
- if (user_val > irq_last) {
- dev_err(dev, "debugfs error input > %d\n", irq_last);
- return -EINVAL;
- }
- irq_index = user_val - irq_first;
- if (irq_index >= num_irqs)
- return -EINVAL;
- /*
- * This will create a sysfs file named <irq-nr> which userspace can
- * use to select or poll and get the AB8500 events
- */
- dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
- GFP_KERNEL);
- if (!dev_attr[irq_index])
- return -ENOMEM;
- event_name[irq_index] = kmalloc(count, GFP_KERNEL);
- if (!event_name[irq_index])
- return -ENOMEM;
- sprintf(event_name[irq_index], "%lu", user_val);
- dev_attr[irq_index]->show = show_irq;
- dev_attr[irq_index]->store = NULL;
- dev_attr[irq_index]->attr.name = event_name[irq_index];
- dev_attr[irq_index]->attr.mode = S_IRUGO;
- err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr);
- if (err < 0) {
- pr_info("sysfs_create_file failed %d\n", err);
- return err;
- }
- err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
- IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT,
- "ab8500-debug", &dev->kobj);
- if (err < 0) {
- pr_info("request_threaded_irq failed %d, %lu\n",
- err, user_val);
- sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
- return err;
- }
- return count;
- }
- static ssize_t ab8500_unsubscribe_write(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
- {
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
- unsigned long user_val;
- int err;
- unsigned int irq_index;
- err = kstrtoul_from_user(user_buf, count, 0, &user_val);
- if (err)
- return err;
- if (user_val < irq_first) {
- dev_err(dev, "debugfs error input < %d\n", irq_first);
- return -EINVAL;
- }
- if (user_val > irq_last) {
- dev_err(dev, "debugfs error input > %d\n", irq_last);
- return -EINVAL;
- }
- irq_index = user_val - irq_first;
- if (irq_index >= num_irqs)
- return -EINVAL;
- /* Set irq count to 0 when unsubscribe */
- irq_count[irq_index] = 0;
- if (dev_attr[irq_index])
- sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
- free_irq(user_val, &dev->kobj);
- kfree(event_name[irq_index]);
- kfree(dev_attr[irq_index]);
- return count;
- }
- /*
- * - several deubgfs nodes fops
- */
- static const struct file_operations ab8500_bank_fops = {
- .open = ab8500_bank_open,
- .write = ab8500_bank_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_address_fops = {
- .open = ab8500_address_open,
- .write = ab8500_address_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_val_fops = {
- .open = ab8500_val_open,
- .write = ab8500_val_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_interrupts_fops = {
- .open = ab8500_interrupts_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_subscribe_fops = {
- .open = ab8500_subscribe_unsubscribe_open,
- .write = ab8500_subscribe_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_unsubscribe_fops = {
- .open = ab8500_subscribe_unsubscribe_open,
- .write = ab8500_unsubscribe_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static const struct file_operations ab8500_hwreg_fops = {
- .open = ab8500_hwreg_open,
- .write = ab8500_hwreg_write,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .owner = THIS_MODULE,
- };
- static struct dentry *ab8500_dir;
- static struct dentry *ab8500_gpadc_dir;
- static int ab8500_debug_probe(struct platform_device *plf)
- {
- struct dentry *file;
- struct ab8500 *ab8500;
- struct resource *res;
- debug_bank = AB8500_MISC;
- debug_address = AB8500_REV_REG & 0x00FF;
- ab8500 = dev_get_drvdata(plf->dev.parent);
- num_irqs = ab8500->mask_size;
- irq_count = devm_kzalloc(&plf->dev,
- sizeof(*irq_count)*num_irqs, GFP_KERNEL);
- if (!irq_count)
- return -ENOMEM;
- dev_attr = devm_kzalloc(&plf->dev,
- sizeof(*dev_attr)*num_irqs, GFP_KERNEL);
- if (!dev_attr)
- return -ENOMEM;
- event_name = devm_kzalloc(&plf->dev,
- sizeof(*event_name)*num_irqs, GFP_KERNEL);
- if (!event_name)
- return -ENOMEM;
- res = platform_get_resource_byname(plf, 0, "IRQ_AB8500");
- if (!res) {
- dev_err(&plf->dev, "AB8500 irq not found, err %d\n", irq_first);
- return -ENXIO;
- }
- irq_ab8500 = res->start;
- irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
- if (irq_first < 0) {
- dev_err(&plf->dev, "First irq not found, err %d\n", irq_first);
- return irq_first;
- }
- irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
- if (irq_last < 0) {
- dev_err(&plf->dev, "Last irq not found, err %d\n", irq_last);
- return irq_last;
- }
- ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
- if (!ab8500_dir)
- goto err;
- ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
- ab8500_dir);
- if (!ab8500_gpadc_dir)
- goto err;
- file = debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir,
- &plf->dev, &ab8500_registers_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("all-banks", S_IRUGO, ab8500_dir,
- &plf->dev, &ab8500_all_banks_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("register-bank",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_dir, &plf->dev, &ab8500_bank_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("register-address",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_dir, &plf->dev, &ab8500_address_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("register-value",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_dir, &plf->dev, &ab8500_val_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("irq-subscribe",
- (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
- &plf->dev, &ab8500_subscribe_fops);
- if (!file)
- goto err;
- if (is_ab8500(ab8500)) {
- debug_ranges = ab8500_debug_ranges;
- num_interrupt_lines = AB8500_NR_IRQS;
- } else if (is_ab8505(ab8500)) {
- debug_ranges = ab8505_debug_ranges;
- num_interrupt_lines = AB8505_NR_IRQS;
- } else if (is_ab9540(ab8500)) {
- debug_ranges = ab8505_debug_ranges;
- num_interrupt_lines = AB9540_NR_IRQS;
- } else if (is_ab8540(ab8500)) {
- debug_ranges = ab8540_debug_ranges;
- num_interrupt_lines = AB8540_NR_IRQS;
- }
- file = debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir,
- &plf->dev, &ab8500_interrupts_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("irq-unsubscribe",
- (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
- &plf->dev, &ab8500_unsubscribe_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("all-modem-registers",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_dir, &plf->dev, &ab8500_modem_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_bat_ctrl_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir,
- &plf->dev, &ab8500_gpadc_btemp_ball_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("main_charger_v",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_main_charger_v_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("acc_detect1",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_acc_detect1_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("acc_detect2",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_acc_detect2_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_aux1_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_aux2_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_main_bat_v_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_vbus_v_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("main_charger_c",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_main_charger_c_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("usb_charger_c",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir,
- &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_bk_bat_v_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_die_temp_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_usb_id_fops);
- if (!file)
- goto err;
- if (is_ab8540(ab8500)) {
- file = debugfs_create_file("xtal_temp",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8540_gpadc_xtal_temp_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("vbattruemeas",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8540_gpadc_vbat_true_meas_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("batctrl_and_ibat",
- (S_IRUGO | S_IWUGO),
- ab8500_gpadc_dir,
- &plf->dev,
- &ab8540_gpadc_bat_ctrl_and_ibat_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("vbatmeas_and_ibat",
- (S_IRUGO | S_IWUGO),
- ab8500_gpadc_dir, &plf->dev,
- &ab8540_gpadc_vbat_meas_and_ibat_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("vbattruemeas_and_ibat",
- (S_IRUGO | S_IWUGO),
- ab8500_gpadc_dir,
- &plf->dev,
- &ab8540_gpadc_vbat_true_meas_and_ibat_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("battemp_and_ibat",
- (S_IRUGO | S_IWUGO),
- ab8500_gpadc_dir,
- &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("otp_calib",
- (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir,
- &plf->dev, &ab8540_gpadc_otp_calib_fops);
- if (!file)
- goto err;
- }
- file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_avg_sample_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_trig_edge_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_trig_timer_fops);
- if (!file)
- goto err;
- file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP),
- ab8500_gpadc_dir, &plf->dev,
- &ab8500_gpadc_conv_type_fops);
- if (!file)
- goto err;
- return 0;
- err:
- debugfs_remove_recursive(ab8500_dir);
- dev_err(&plf->dev, "failed to create debugfs entries.\n");
- return -ENOMEM;
- }
- static int ab8500_debug_remove(struct platform_device *plf)
- {
- debugfs_remove_recursive(ab8500_dir);
- return 0;
- }
- static struct platform_driver ab8500_debug_driver = {
- .driver = {
- .name = "ab8500-debug",
- },
- .probe = ab8500_debug_probe,
- .remove = ab8500_debug_remove
- };
- static int __init ab8500_debug_init(void)
- {
- return platform_driver_register(&ab8500_debug_driver);
- }
- static void __exit ab8500_debug_exit(void)
- {
- platform_driver_unregister(&ab8500_debug_driver);
- }
- subsys_initcall(ab8500_debug_init);
- module_exit(ab8500_debug_exit);
- MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
- MODULE_DESCRIPTION("AB8500 DEBUG");
- MODULE_LICENSE("GPL v2");
|