orangepi-zero3.patch 137 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007
  1. From 16e07c5e69b4cec6bea87fd616d05e9af33b565b Mon Sep 17 00:00:00 2001
  2. From: Chukun Pan <[email protected]>
  3. Date: Fri, 5 Jan 2024 23:16:16 +0800
  4. Subject: [PATCH 1/4] uboot-sunxi: bump to 2024.01
  5. This version supports LPDDR4 DRAM of H618 SoC.
  6. Tested on Orange Pi Zero 3.
  7. Signed-off-by: Chukun Pan <[email protected]>
  8. ---
  9. package/boot/uboot-sunxi/Makefile | 4 ++--
  10. .../uboot-sunxi/patches/062-A20-improve-gmac-upload.patch | 2 +-
  11. ...00-mkimage-check-environment-for-dtc-binary-location.patch | 2 +-
  12. 3 files changed, 4 insertions(+), 4 deletions(-)
  13. diff --git a/package/boot/uboot-sunxi/Makefile b/package/boot/uboot-sunxi/Makefile
  14. index 7f50992e6955c..de07dbdec2e97 100644
  15. --- a/package/boot/uboot-sunxi/Makefile
  16. +++ b/package/boot/uboot-sunxi/Makefile
  17. @@ -9,9 +9,9 @@
  18. include $(TOPDIR)/rules.mk
  19. include $(INCLUDE_DIR)/kernel.mk
  20. -PKG_VERSION:=2023.04
  21. +PKG_VERSION:=2024.01
  22. -PKG_HASH:=e31cac91545ff41b71cec5d8c22afd695645cd6e2a442ccdacacd60534069341
  23. +PKG_HASH:=b99611f1ed237bf3541bdc8434b68c96a6e05967061f992443cb30aabebef5b3
  24. PKG_MAINTAINER:=Zoltan HERPAI <[email protected]>
  25. diff --git a/package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch b/package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch
  26. index 13a703f307d21..a1caf18a184a5 100644
  27. --- a/package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch
  28. +++ b/package/boot/uboot-sunxi/patches/062-A20-improve-gmac-upload.patch
  29. @@ -2,7 +2,7 @@
  30. --- a/configs/A20-OLinuXino-Lime2_defconfig
  31. +++ b/configs/A20-OLinuXino-Lime2_defconfig
  32. -@@ -26,6 +26,7 @@ CONFIG_ETH_DESIGNWARE=y
  33. +@@ -25,6 +25,7 @@ CONFIG_ETH_DESIGNWARE=y
  34. CONFIG_RGMII=y
  35. CONFIG_MII=y
  36. CONFIG_SUN7I_GMAC=y
  37. diff --git a/package/boot/uboot-sunxi/patches/200-mkimage-check-environment-for-dtc-binary-location.patch b/package/boot/uboot-sunxi/patches/200-mkimage-check-environment-for-dtc-binary-location.patch
  38. index fcc30ce35cd1d..0307d6b99b2e2 100644
  39. --- a/package/boot/uboot-sunxi/patches/200-mkimage-check-environment-for-dtc-binary-location.patch
  40. +++ b/package/boot/uboot-sunxi/patches/200-mkimage-check-environment-for-dtc-binary-location.patch
  41. @@ -17,7 +17,7 @@ Cc: Simon Glass <[email protected]>
  42. --- a/tools/fit_image.c
  43. +++ b/tools/fit_image.c
  44. -@@ -754,9 +754,14 @@ static int fit_handle_file(struct image_
  45. +@@ -774,9 +774,14 @@ static int fit_handle_file(struct image_
  46. }
  47. *cmd = '\0';
  48. } else if (params->datafile) {
  49. From b59981e7f7e83468ce3604877307d620a9e48f18 Mon Sep 17 00:00:00 2001
  50. From: Chukun Pan <[email protected]>
  51. Date: Thu, 16 Nov 2023 23:10:21 +0800
  52. Subject: [PATCH 2/4] generic: 6.1: backport AXP PMIC support
  53. Backport AXP15060, AXP313a and AXP192 support.
  54. The AXP15060 PMIC is used for starfive boards,
  55. and the AXP313a PMIC is used for sunxi boards.
  56. Remove conflicting patches from starfive target.
  57. Signed-off-by: Chukun Pan <[email protected]>
  58. ---
  59. ...0x-Switch-to-the-sys-off-handler-API.patch | 82 ++
  60. ...axp20x-Add-support-for-AXP15060-PMIC.patch | 343 ++++++
  61. ...-axp20x-Add-support-for-AXP313a-PMIC.patch | 256 +++++
  62. ...p20x-Add-support-for-AXP313a-variant.patch | 129 +++
  63. ...gulator-axp20x-Add-AXP15060-support.patch} | 159 +--
  64. ....5-mfd-axp20x-Add-support-for-AXP192.patch | 383 +++++++
  65. ...-mfd-axp20x-Add-support-for-AXP15060.patch | 1014 -----------------
  66. 7 files changed, 1239 insertions(+), 1127 deletions(-)
  67. create mode 100644 target/linux/generic/backport-6.1/850-v6.3-mfd-axp20x-Switch-to-the-sys-off-handler-API.patch
  68. create mode 100644 target/linux/generic/backport-6.1/851-v6.4-mfd-axp20x-Add-support-for-AXP15060-PMIC.patch
  69. create mode 100644 target/linux/generic/backport-6.1/852-v6.5-mfd-axp20x-Add-support-for-AXP313a-PMIC.patch
  70. create mode 100644 target/linux/generic/backport-6.1/853-v6.5-regulator-axp20x-Add-support-for-AXP313a-variant.patch
  71. rename target/linux/{starfive/patches-6.1/0118-driver-regulator-axp20x-Support-AXP15060-variant.patch => generic/backport-6.1/854-v6.5-regulator-axp20x-Add-AXP15060-support.patch} (74%)
  72. create mode 100644 target/linux/generic/backport-6.1/855-v6.5-mfd-axp20x-Add-support-for-AXP192.patch
  73. delete mode 100644 target/linux/starfive/patches-6.1/0117-driver-mfd-axp20x-Add-support-for-AXP15060.patch
  74. diff --git a/target/linux/generic/backport-6.1/850-v6.3-mfd-axp20x-Switch-to-the-sys-off-handler-API.patch b/target/linux/generic/backport-6.1/850-v6.3-mfd-axp20x-Switch-to-the-sys-off-handler-API.patch
  75. new file mode 100644
  76. index 0000000000000..b742276c8ad43
  77. --- /dev/null
  78. +++ b/target/linux/generic/backport-6.1/850-v6.3-mfd-axp20x-Switch-to-the-sys-off-handler-API.patch
  79. @@ -0,0 +1,82 @@
  80. +From 1b1305e95e85624f538ec56db9acf88e2d3d7397 Mon Sep 17 00:00:00 2001
  81. +From: Samuel Holland <[email protected]>
  82. +Date: Wed, 28 Dec 2022 10:27:52 -0600
  83. +Subject: [PATCH] mfd: axp20x: Switch to the sys-off handler API
  84. +
  85. +This removes a layer of indirection through pm_power_off() and allows
  86. +the PMIC handler to be used as a fallback when firmware power off fails.
  87. +This happens on boards like the Clockwork DevTerm R-01 where OpenSBI
  88. +does not know how to use the PMIC to power off the board.
  89. +
  90. +Move the check for AXP288 to avoid registering a dummy handler.
  91. +
  92. +Signed-off-by: Samuel Holland <[email protected]>
  93. +[Lee: Removed superfluous new line]
  94. +Signed-off-by: Lee Jones <[email protected]>
  95. +Link: https://lore.kernel.org/r/[email protected]
  96. +---
  97. + drivers/mfd/axp20x.c | 27 +++++++++++----------------
  98. + 1 file changed, 11 insertions(+), 16 deletions(-)
  99. +
  100. +--- a/drivers/mfd/axp20x.c
  101. ++++ b/drivers/mfd/axp20x.c
  102. +@@ -23,7 +23,7 @@
  103. + #include <linux/mfd/core.h>
  104. + #include <linux/module.h>
  105. + #include <linux/of_device.h>
  106. +-#include <linux/pm_runtime.h>
  107. ++#include <linux/reboot.h>
  108. + #include <linux/regmap.h>
  109. + #include <linux/regulator/consumer.h>
  110. +
  111. +@@ -832,17 +832,16 @@ static const struct mfd_cell axp813_cell
  112. + },
  113. + };
  114. +
  115. +-static struct axp20x_dev *axp20x_pm_power_off;
  116. +-static void axp20x_power_off(void)
  117. ++static int axp20x_power_off(struct sys_off_data *data)
  118. + {
  119. +- if (axp20x_pm_power_off->variant == AXP288_ID)
  120. +- return;
  121. ++ struct axp20x_dev *axp20x = data->cb_data;
  122. +
  123. +- regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
  124. +- AXP20X_OFF);
  125. ++ regmap_write(axp20x->regmap, AXP20X_OFF_CTRL, AXP20X_OFF);
  126. +
  127. + /* Give capacitors etc. time to drain to avoid kernel panic msg. */
  128. + mdelay(500);
  129. ++
  130. ++ return NOTIFY_DONE;
  131. + }
  132. +
  133. + int axp20x_match_device(struct axp20x_dev *axp20x)
  134. +@@ -1009,10 +1008,11 @@ int axp20x_device_probe(struct axp20x_de
  135. + return ret;
  136. + }
  137. +
  138. +- if (!pm_power_off) {
  139. +- axp20x_pm_power_off = axp20x;
  140. +- pm_power_off = axp20x_power_off;
  141. +- }
  142. ++ if (axp20x->variant != AXP288_ID)
  143. ++ devm_register_sys_off_handler(axp20x->dev,
  144. ++ SYS_OFF_MODE_POWER_OFF,
  145. ++ SYS_OFF_PRIO_DEFAULT,
  146. ++ axp20x_power_off, axp20x);
  147. +
  148. + dev_info(axp20x->dev, "AXP20X driver loaded\n");
  149. +
  150. +@@ -1022,11 +1022,6 @@ EXPORT_SYMBOL(axp20x_device_probe);
  151. +
  152. + void axp20x_device_remove(struct axp20x_dev *axp20x)
  153. + {
  154. +- if (axp20x == axp20x_pm_power_off) {
  155. +- axp20x_pm_power_off = NULL;
  156. +- pm_power_off = NULL;
  157. +- }
  158. +-
  159. + mfd_remove_devices(axp20x->dev);
  160. + regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
  161. + }
  162. diff --git a/target/linux/generic/backport-6.1/851-v6.4-mfd-axp20x-Add-support-for-AXP15060-PMIC.patch b/target/linux/generic/backport-6.1/851-v6.4-mfd-axp20x-Add-support-for-AXP15060-PMIC.patch
  163. new file mode 100644
  164. index 0000000000000..ec8d38a183a72
  165. --- /dev/null
  166. +++ b/target/linux/generic/backport-6.1/851-v6.4-mfd-axp20x-Add-support-for-AXP15060-PMIC.patch
  167. @@ -0,0 +1,343 @@
  168. +From e0f8ad2a705367518b5c56bf9d6da89681467c02 Mon Sep 17 00:00:00 2001
  169. +From: Shengyu Qu <[email protected]>
  170. +Date: Fri, 21 Apr 2023 23:08:15 +0800
  171. +Subject: [PATCH] mfd: axp20x: Add support for AXP15060 PMIC
  172. +
  173. +The AXP15060 is a PMIC chip produced by X-Powers, and could be connected
  174. +via an I2C bus.
  175. +
  176. +Describe the regmap and the MFD bits, along with the registers exposed
  177. +via I2C. Eventually advertise the device using a new compatible string
  178. +and add support for power off the system.
  179. +
  180. +The driver would disable PEK function if IRQ is not configured in device
  181. +tree, since some boards (For example, Starfive Visionfive 2) didn't
  182. +connect IRQ line of PMIC to SOC.
  183. +
  184. +GPIO function isn't enabled in this commit, since its configuration
  185. +operation is different from any existing AXP PMICs and needs
  186. +logic modification on existing driver. GPIO support might come in later
  187. +patches.
  188. +
  189. +Signed-off-by: Shengyu Qu <[email protected]>
  190. +Reviewed-by: Krzysztof Kozlowski <[email protected]>
  191. +Signed-off-by: Lee Jones <[email protected]>
  192. +Link: https://lore.kernel.org/r/TY3P286MB261162D57695AC8164ED50E298609@TY3P286MB2611.JPNP286.PROD.OUTLOOK.COM
  193. +---
  194. + drivers/mfd/axp20x-i2c.c | 2 +
  195. + drivers/mfd/axp20x.c | 107 +++++++++++++++++++++++++++++++++++++
  196. + include/linux/mfd/axp20x.h | 85 +++++++++++++++++++++++++++++
  197. + 3 files changed, 194 insertions(+)
  198. +
  199. +--- a/drivers/mfd/axp20x-i2c.c
  200. ++++ b/drivers/mfd/axp20x-i2c.c
  201. +@@ -66,6 +66,7 @@ static const struct of_device_id axp20x_
  202. + { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
  203. + { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
  204. + { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
  205. ++ { .compatible = "x-powers,axp15060", .data = (void *)AXP15060_ID },
  206. + { },
  207. + };
  208. + MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match);
  209. +@@ -79,6 +80,7 @@ static const struct i2c_device_id axp20x
  210. + { "axp223", 0 },
  211. + { "axp803", 0 },
  212. + { "axp806", 0 },
  213. ++ { "axp15060", 0 },
  214. + { },
  215. + };
  216. + MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
  217. +--- a/drivers/mfd/axp20x.c
  218. ++++ b/drivers/mfd/axp20x.c
  219. +@@ -43,6 +43,7 @@ static const char * const axp20x_model_n
  220. + "AXP806",
  221. + "AXP809",
  222. + "AXP813",
  223. ++ "AXP15060",
  224. + };
  225. +
  226. + static const struct regmap_range axp152_writeable_ranges[] = {
  227. +@@ -168,6 +169,31 @@ static const struct regmap_access_table
  228. + .n_yes_ranges = ARRAY_SIZE(axp806_volatile_ranges),
  229. + };
  230. +
  231. ++static const struct regmap_range axp15060_writeable_ranges[] = {
  232. ++ regmap_reg_range(AXP15060_PWR_OUT_CTRL1, AXP15060_DCDC_MODE_CTRL2),
  233. ++ regmap_reg_range(AXP15060_OUTPUT_MONITOR_DISCHARGE, AXP15060_CPUSLDO_V_CTRL),
  234. ++ regmap_reg_range(AXP15060_PWR_WAKEUP_CTRL, AXP15060_PWR_DISABLE_DOWN_SEQ),
  235. ++ regmap_reg_range(AXP15060_PEK_KEY, AXP15060_PEK_KEY),
  236. ++ regmap_reg_range(AXP15060_IRQ1_EN, AXP15060_IRQ2_EN),
  237. ++ regmap_reg_range(AXP15060_IRQ1_STATE, AXP15060_IRQ2_STATE),
  238. ++};
  239. ++
  240. ++static const struct regmap_range axp15060_volatile_ranges[] = {
  241. ++ regmap_reg_range(AXP15060_STARTUP_SRC, AXP15060_STARTUP_SRC),
  242. ++ regmap_reg_range(AXP15060_PWR_WAKEUP_CTRL, AXP15060_PWR_DISABLE_DOWN_SEQ),
  243. ++ regmap_reg_range(AXP15060_IRQ1_STATE, AXP15060_IRQ2_STATE),
  244. ++};
  245. ++
  246. ++static const struct regmap_access_table axp15060_writeable_table = {
  247. ++ .yes_ranges = axp15060_writeable_ranges,
  248. ++ .n_yes_ranges = ARRAY_SIZE(axp15060_writeable_ranges),
  249. ++};
  250. ++
  251. ++static const struct regmap_access_table axp15060_volatile_table = {
  252. ++ .yes_ranges = axp15060_volatile_ranges,
  253. ++ .n_yes_ranges = ARRAY_SIZE(axp15060_volatile_ranges),
  254. ++};
  255. ++
  256. + static const struct resource axp152_pek_resources[] = {
  257. + DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  258. + DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  259. +@@ -236,6 +262,11 @@ static const struct resource axp809_pek_
  260. + DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  261. + };
  262. +
  263. ++static const struct resource axp15060_pek_resources[] = {
  264. ++ DEFINE_RES_IRQ_NAMED(AXP15060_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  265. ++ DEFINE_RES_IRQ_NAMED(AXP15060_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  266. ++};
  267. ++
  268. + static const struct regmap_config axp152_regmap_config = {
  269. + .reg_bits = 8,
  270. + .val_bits = 8,
  271. +@@ -281,6 +312,15 @@ static const struct regmap_config axp806
  272. + .cache_type = REGCACHE_RBTREE,
  273. + };
  274. +
  275. ++static const struct regmap_config axp15060_regmap_config = {
  276. ++ .reg_bits = 8,
  277. ++ .val_bits = 8,
  278. ++ .wr_table = &axp15060_writeable_table,
  279. ++ .volatile_table = &axp15060_volatile_table,
  280. ++ .max_register = AXP15060_IRQ2_STATE,
  281. ++ .cache_type = REGCACHE_RBTREE,
  282. ++};
  283. ++
  284. + #define INIT_REGMAP_IRQ(_variant, _irq, _off, _mask) \
  285. + [_variant##_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
  286. +
  287. +@@ -502,6 +542,23 @@ static const struct regmap_irq axp809_re
  288. + INIT_REGMAP_IRQ(AXP809, GPIO0_INPUT, 4, 0),
  289. + };
  290. +
  291. ++static const struct regmap_irq axp15060_regmap_irqs[] = {
  292. ++ INIT_REGMAP_IRQ(AXP15060, DIE_TEMP_HIGH_LV1, 0, 0),
  293. ++ INIT_REGMAP_IRQ(AXP15060, DIE_TEMP_HIGH_LV2, 0, 1),
  294. ++ INIT_REGMAP_IRQ(AXP15060, DCDC1_V_LOW, 0, 2),
  295. ++ INIT_REGMAP_IRQ(AXP15060, DCDC2_V_LOW, 0, 3),
  296. ++ INIT_REGMAP_IRQ(AXP15060, DCDC3_V_LOW, 0, 4),
  297. ++ INIT_REGMAP_IRQ(AXP15060, DCDC4_V_LOW, 0, 5),
  298. ++ INIT_REGMAP_IRQ(AXP15060, DCDC5_V_LOW, 0, 6),
  299. ++ INIT_REGMAP_IRQ(AXP15060, DCDC6_V_LOW, 0, 7),
  300. ++ INIT_REGMAP_IRQ(AXP15060, PEK_LONG, 1, 0),
  301. ++ INIT_REGMAP_IRQ(AXP15060, PEK_SHORT, 1, 1),
  302. ++ INIT_REGMAP_IRQ(AXP15060, GPIO1_INPUT, 1, 2),
  303. ++ INIT_REGMAP_IRQ(AXP15060, PEK_FAL_EDGE, 1, 3),
  304. ++ INIT_REGMAP_IRQ(AXP15060, PEK_RIS_EDGE, 1, 4),
  305. ++ INIT_REGMAP_IRQ(AXP15060, GPIO2_INPUT, 1, 5),
  306. ++};
  307. ++
  308. + static const struct regmap_irq_chip axp152_regmap_irq_chip = {
  309. + .name = "axp152_irq_chip",
  310. + .status_base = AXP152_IRQ1_STATE,
  311. +@@ -588,6 +645,17 @@ static const struct regmap_irq_chip axp8
  312. + .num_regs = 5,
  313. + };
  314. +
  315. ++static const struct regmap_irq_chip axp15060_regmap_irq_chip = {
  316. ++ .name = "axp15060",
  317. ++ .status_base = AXP15060_IRQ1_STATE,
  318. ++ .ack_base = AXP15060_IRQ1_STATE,
  319. ++ .unmask_base = AXP15060_IRQ1_EN,
  320. ++ .init_ack_masked = true,
  321. ++ .irqs = axp15060_regmap_irqs,
  322. ++ .num_irqs = ARRAY_SIZE(axp15060_regmap_irqs),
  323. ++ .num_regs = 2,
  324. ++};
  325. ++
  326. + static const struct mfd_cell axp20x_cells[] = {
  327. + {
  328. + .name = "axp20x-gpio",
  329. +@@ -832,6 +900,23 @@ static const struct mfd_cell axp813_cell
  330. + },
  331. + };
  332. +
  333. ++static const struct mfd_cell axp15060_cells[] = {
  334. ++ {
  335. ++ .name = "axp221-pek",
  336. ++ .num_resources = ARRAY_SIZE(axp15060_pek_resources),
  337. ++ .resources = axp15060_pek_resources,
  338. ++ }, {
  339. ++ .name = "axp20x-regulator",
  340. ++ },
  341. ++};
  342. ++
  343. ++/* For boards that don't have IRQ line connected to SOC. */
  344. ++static const struct mfd_cell axp_regulator_only_cells[] = {
  345. ++ {
  346. ++ .name = "axp20x-regulator",
  347. ++ },
  348. ++};
  349. ++
  350. + static int axp20x_power_off(struct sys_off_data *data)
  351. + {
  352. + struct axp20x_dev *axp20x = data->cb_data;
  353. +@@ -941,6 +1026,28 @@ int axp20x_match_device(struct axp20x_de
  354. + */
  355. + axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
  356. + break;
  357. ++ case AXP15060_ID:
  358. ++ /*
  359. ++ * Don't register the power key part if there is no interrupt
  360. ++ * line.
  361. ++ *
  362. ++ * Since most use cases of AXP PMICs are Allwinner SOCs, board
  363. ++ * designers follow Allwinner's reference design and connects
  364. ++ * IRQ line to SOC, there's no need for those variants to deal
  365. ++ * with cases that IRQ isn't connected. However, AXP15660 is
  366. ++ * used by some other vendors' SOCs that didn't connect IRQ
  367. ++ * line, we need to deal with this case.
  368. ++ */
  369. ++ if (axp20x->irq > 0) {
  370. ++ axp20x->nr_cells = ARRAY_SIZE(axp15060_cells);
  371. ++ axp20x->cells = axp15060_cells;
  372. ++ } else {
  373. ++ axp20x->nr_cells = ARRAY_SIZE(axp_regulator_only_cells);
  374. ++ axp20x->cells = axp_regulator_only_cells;
  375. ++ }
  376. ++ axp20x->regmap_cfg = &axp15060_regmap_config;
  377. ++ axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip;
  378. ++ break;
  379. + default:
  380. + dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
  381. + return -EINVAL;
  382. +--- a/include/linux/mfd/axp20x.h
  383. ++++ b/include/linux/mfd/axp20x.h
  384. +@@ -21,6 +21,7 @@ enum axp20x_variants {
  385. + AXP806_ID,
  386. + AXP809_ID,
  387. + AXP813_ID,
  388. ++ AXP15060_ID,
  389. + NR_AXP20X_VARIANTS,
  390. + };
  391. +
  392. +@@ -131,6 +132,39 @@ enum axp20x_variants {
  393. + /* Other DCDC regulator control registers are the same as AXP803 */
  394. + #define AXP813_DCDC7_V_OUT 0x26
  395. +
  396. ++#define AXP15060_STARTUP_SRC 0x00
  397. ++#define AXP15060_PWR_OUT_CTRL1 0x10
  398. ++#define AXP15060_PWR_OUT_CTRL2 0x11
  399. ++#define AXP15060_PWR_OUT_CTRL3 0x12
  400. ++#define AXP15060_DCDC1_V_CTRL 0x13
  401. ++#define AXP15060_DCDC2_V_CTRL 0x14
  402. ++#define AXP15060_DCDC3_V_CTRL 0x15
  403. ++#define AXP15060_DCDC4_V_CTRL 0x16
  404. ++#define AXP15060_DCDC5_V_CTRL 0x17
  405. ++#define AXP15060_DCDC6_V_CTRL 0x18
  406. ++#define AXP15060_ALDO1_V_CTRL 0x19
  407. ++#define AXP15060_DCDC_MODE_CTRL1 0x1a
  408. ++#define AXP15060_DCDC_MODE_CTRL2 0x1b
  409. ++#define AXP15060_OUTPUT_MONITOR_DISCHARGE 0x1e
  410. ++#define AXP15060_IRQ_PWROK_VOFF 0x1f
  411. ++#define AXP15060_ALDO2_V_CTRL 0x20
  412. ++#define AXP15060_ALDO3_V_CTRL 0x21
  413. ++#define AXP15060_ALDO4_V_CTRL 0x22
  414. ++#define AXP15060_ALDO5_V_CTRL 0x23
  415. ++#define AXP15060_BLDO1_V_CTRL 0x24
  416. ++#define AXP15060_BLDO2_V_CTRL 0x25
  417. ++#define AXP15060_BLDO3_V_CTRL 0x26
  418. ++#define AXP15060_BLDO4_V_CTRL 0x27
  419. ++#define AXP15060_BLDO5_V_CTRL 0x28
  420. ++#define AXP15060_CLDO1_V_CTRL 0x29
  421. ++#define AXP15060_CLDO2_V_CTRL 0x2a
  422. ++#define AXP15060_CLDO3_V_CTRL 0x2b
  423. ++#define AXP15060_CLDO4_V_CTRL 0x2d
  424. ++#define AXP15060_CPUSLDO_V_CTRL 0x2e
  425. ++#define AXP15060_PWR_WAKEUP_CTRL 0x31
  426. ++#define AXP15060_PWR_DISABLE_DOWN_SEQ 0x32
  427. ++#define AXP15060_PEK_KEY 0x36
  428. ++
  429. + /* Interrupt */
  430. + #define AXP152_IRQ1_EN 0x40
  431. + #define AXP152_IRQ2_EN 0x41
  432. +@@ -152,6 +186,11 @@ enum axp20x_variants {
  433. + #define AXP20X_IRQ5_STATE 0x4c
  434. + #define AXP20X_IRQ6_STATE 0x4d
  435. +
  436. ++#define AXP15060_IRQ1_EN 0x40
  437. ++#define AXP15060_IRQ2_EN 0x41
  438. ++#define AXP15060_IRQ1_STATE 0x48
  439. ++#define AXP15060_IRQ2_STATE 0x49
  440. ++
  441. + /* ADC */
  442. + #define AXP20X_ACIN_V_ADC_H 0x56
  443. + #define AXP20X_ACIN_V_ADC_L 0x57
  444. +@@ -222,6 +261,8 @@ enum axp20x_variants {
  445. + #define AXP22X_GPIO_STATE 0x94
  446. + #define AXP22X_GPIO_PULL_DOWN 0x95
  447. +
  448. ++#define AXP15060_CLDO4_GPIO2_MODESET 0x2c
  449. ++
  450. + /* Battery */
  451. + #define AXP20X_CHRG_CC_31_24 0xb0
  452. + #define AXP20X_CHRG_CC_23_16 0xb1
  453. +@@ -419,6 +460,33 @@ enum {
  454. + AXP813_REG_ID_MAX,
  455. + };
  456. +
  457. ++enum {
  458. ++ AXP15060_DCDC1 = 0,
  459. ++ AXP15060_DCDC2,
  460. ++ AXP15060_DCDC3,
  461. ++ AXP15060_DCDC4,
  462. ++ AXP15060_DCDC5,
  463. ++ AXP15060_DCDC6,
  464. ++ AXP15060_ALDO1,
  465. ++ AXP15060_ALDO2,
  466. ++ AXP15060_ALDO3,
  467. ++ AXP15060_ALDO4,
  468. ++ AXP15060_ALDO5,
  469. ++ AXP15060_BLDO1,
  470. ++ AXP15060_BLDO2,
  471. ++ AXP15060_BLDO3,
  472. ++ AXP15060_BLDO4,
  473. ++ AXP15060_BLDO5,
  474. ++ AXP15060_CLDO1,
  475. ++ AXP15060_CLDO2,
  476. ++ AXP15060_CLDO3,
  477. ++ AXP15060_CLDO4,
  478. ++ AXP15060_CPUSLDO,
  479. ++ AXP15060_SW,
  480. ++ AXP15060_RTC_LDO,
  481. ++ AXP15060_REG_ID_MAX,
  482. ++};
  483. ++
  484. + /* IRQs */
  485. + enum {
  486. + AXP152_IRQ_LDO0IN_CONNECT = 1,
  487. +@@ -632,6 +700,23 @@ enum axp809_irqs {
  488. + AXP809_IRQ_GPIO0_INPUT,
  489. + };
  490. +
  491. ++enum axp15060_irqs {
  492. ++ AXP15060_IRQ_DIE_TEMP_HIGH_LV1 = 1,
  493. ++ AXP15060_IRQ_DIE_TEMP_HIGH_LV2,
  494. ++ AXP15060_IRQ_DCDC1_V_LOW,
  495. ++ AXP15060_IRQ_DCDC2_V_LOW,
  496. ++ AXP15060_IRQ_DCDC3_V_LOW,
  497. ++ AXP15060_IRQ_DCDC4_V_LOW,
  498. ++ AXP15060_IRQ_DCDC5_V_LOW,
  499. ++ AXP15060_IRQ_DCDC6_V_LOW,
  500. ++ AXP15060_IRQ_PEK_LONG,
  501. ++ AXP15060_IRQ_PEK_SHORT,
  502. ++ AXP15060_IRQ_GPIO1_INPUT,
  503. ++ AXP15060_IRQ_PEK_FAL_EDGE,
  504. ++ AXP15060_IRQ_PEK_RIS_EDGE,
  505. ++ AXP15060_IRQ_GPIO2_INPUT,
  506. ++};
  507. ++
  508. + struct axp20x_dev {
  509. + struct device *dev;
  510. + int irq;
  511. diff --git a/target/linux/generic/backport-6.1/852-v6.5-mfd-axp20x-Add-support-for-AXP313a-PMIC.patch b/target/linux/generic/backport-6.1/852-v6.5-mfd-axp20x-Add-support-for-AXP313a-PMIC.patch
  512. new file mode 100644
  513. index 0000000000000..9fe70c1032f6f
  514. --- /dev/null
  515. +++ b/target/linux/generic/backport-6.1/852-v6.5-mfd-axp20x-Add-support-for-AXP313a-PMIC.patch
  516. @@ -0,0 +1,256 @@
  517. +From 75c8cb2f4cb218aaf4ea68cab08d6dbc96eeae15 Mon Sep 17 00:00:00 2001
  518. +From: Martin Botka <[email protected]>
  519. +Date: Wed, 24 May 2023 01:00:10 +0100
  520. +Subject: [PATCH] mfd: axp20x: Add support for AXP313a PMIC
  521. +
  522. +The AXP313a is a PMIC chip produced by X-Powers, it can be connected via
  523. +an I2C bus.
  524. +The name AXP1530 seems to appear as well, and this is what is used in
  525. +the BSP driver. From all we know it's the same chip, just a different
  526. +name. However we have only seen AXP313a chips in the wild, so go with
  527. +this name.
  528. +
  529. +Compared to the other AXP PMICs it's a rather simple affair: just three
  530. +DCDC converters, three LDOs, and no battery charging support.
  531. +
  532. +Describe the regmap and the MFD bits, along with the registers exposed
  533. +via I2C. Aside from the various regulators, also describe the power key
  534. +interrupts, and adjust the shutdown handler routine to use a different
  535. +register than the other PMICs.
  536. +Eventually advertise the device using the new compatible string.
  537. +
  538. +Signed-off-by: Martin Botka <[email protected]>
  539. +Signed-off-by: Andre Przywara <[email protected]>
  540. +Reviewed-by: Chen-Yu Tsai <[email protected]>
  541. +Link: https://lore.kernel.org/r/[email protected]
  542. +Signed-off-by: Lee Jones <[email protected]>
  543. +---
  544. + drivers/mfd/axp20x-i2c.c | 2 +
  545. + drivers/mfd/axp20x.c | 78 +++++++++++++++++++++++++++++++++++++-
  546. + include/linux/mfd/axp20x.h | 32 ++++++++++++++++
  547. + 3 files changed, 111 insertions(+), 1 deletion(-)
  548. +
  549. +--- a/drivers/mfd/axp20x-i2c.c
  550. ++++ b/drivers/mfd/axp20x-i2c.c
  551. +@@ -64,6 +64,7 @@ static const struct of_device_id axp20x_
  552. + { .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
  553. + { .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
  554. + { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
  555. ++ { .compatible = "x-powers,axp313a", .data = (void *)AXP313A_ID },
  556. + { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
  557. + { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
  558. + { .compatible = "x-powers,axp15060", .data = (void *)AXP15060_ID },
  559. +@@ -78,6 +79,7 @@ static const struct i2c_device_id axp20x
  560. + { "axp209", 0 },
  561. + { "axp221", 0 },
  562. + { "axp223", 0 },
  563. ++ { "axp313a", 0 },
  564. + { "axp803", 0 },
  565. + { "axp806", 0 },
  566. + { "axp15060", 0 },
  567. +--- a/drivers/mfd/axp20x.c
  568. ++++ b/drivers/mfd/axp20x.c
  569. +@@ -39,6 +39,7 @@ static const char * const axp20x_model_n
  570. + "AXP221",
  571. + "AXP223",
  572. + "AXP288",
  573. ++ "AXP313a",
  574. + "AXP803",
  575. + "AXP806",
  576. + "AXP809",
  577. +@@ -155,6 +156,25 @@ static const struct regmap_range axp806_
  578. + regmap_reg_range(AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT),
  579. + };
  580. +
  581. ++static const struct regmap_range axp313a_writeable_ranges[] = {
  582. ++ regmap_reg_range(AXP313A_ON_INDICATE, AXP313A_IRQ_STATE),
  583. ++};
  584. ++
  585. ++static const struct regmap_range axp313a_volatile_ranges[] = {
  586. ++ regmap_reg_range(AXP313A_SHUTDOWN_CTRL, AXP313A_SHUTDOWN_CTRL),
  587. ++ regmap_reg_range(AXP313A_IRQ_STATE, AXP313A_IRQ_STATE),
  588. ++};
  589. ++
  590. ++static const struct regmap_access_table axp313a_writeable_table = {
  591. ++ .yes_ranges = axp313a_writeable_ranges,
  592. ++ .n_yes_ranges = ARRAY_SIZE(axp313a_writeable_ranges),
  593. ++};
  594. ++
  595. ++static const struct regmap_access_table axp313a_volatile_table = {
  596. ++ .yes_ranges = axp313a_volatile_ranges,
  597. ++ .n_yes_ranges = ARRAY_SIZE(axp313a_volatile_ranges),
  598. ++};
  599. ++
  600. + static const struct regmap_range axp806_volatile_ranges[] = {
  601. + regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE),
  602. + };
  603. +@@ -247,6 +267,11 @@ static const struct resource axp288_fuel
  604. + DEFINE_RES_IRQ(AXP288_IRQ_WL1),
  605. + };
  606. +
  607. ++static const struct resource axp313a_pek_resources[] = {
  608. ++ DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  609. ++ DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  610. ++};
  611. ++
  612. + static const struct resource axp803_pek_resources[] = {
  613. + DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  614. + DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  615. +@@ -303,6 +328,15 @@ static const struct regmap_config axp288
  616. + .cache_type = REGCACHE_RBTREE,
  617. + };
  618. +
  619. ++static const struct regmap_config axp313a_regmap_config = {
  620. ++ .reg_bits = 8,
  621. ++ .val_bits = 8,
  622. ++ .wr_table = &axp313a_writeable_table,
  623. ++ .volatile_table = &axp313a_volatile_table,
  624. ++ .max_register = AXP313A_IRQ_STATE,
  625. ++ .cache_type = REGCACHE_RBTREE,
  626. ++};
  627. ++
  628. + static const struct regmap_config axp806_regmap_config = {
  629. + .reg_bits = 8,
  630. + .val_bits = 8,
  631. +@@ -455,6 +489,16 @@ static const struct regmap_irq axp288_re
  632. + INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1),
  633. + };
  634. +
  635. ++static const struct regmap_irq axp313a_regmap_irqs[] = {
  636. ++ INIT_REGMAP_IRQ(AXP313A, PEK_RIS_EDGE, 0, 7),
  637. ++ INIT_REGMAP_IRQ(AXP313A, PEK_FAL_EDGE, 0, 6),
  638. ++ INIT_REGMAP_IRQ(AXP313A, PEK_SHORT, 0, 5),
  639. ++ INIT_REGMAP_IRQ(AXP313A, PEK_LONG, 0, 4),
  640. ++ INIT_REGMAP_IRQ(AXP313A, DCDC3_V_LOW, 0, 3),
  641. ++ INIT_REGMAP_IRQ(AXP313A, DCDC2_V_LOW, 0, 2),
  642. ++ INIT_REGMAP_IRQ(AXP313A, DIE_TEMP_HIGH, 0, 0),
  643. ++};
  644. ++
  645. + static const struct regmap_irq axp803_regmap_irqs[] = {
  646. + INIT_REGMAP_IRQ(AXP803, ACIN_OVER_V, 0, 7),
  647. + INIT_REGMAP_IRQ(AXP803, ACIN_PLUGIN, 0, 6),
  648. +@@ -609,6 +653,17 @@ static const struct regmap_irq_chip axp2
  649. +
  650. + };
  651. +
  652. ++static const struct regmap_irq_chip axp313a_regmap_irq_chip = {
  653. ++ .name = "axp313a_irq_chip",
  654. ++ .status_base = AXP313A_IRQ_STATE,
  655. ++ .ack_base = AXP313A_IRQ_STATE,
  656. ++ .unmask_base = AXP313A_IRQ_EN,
  657. ++ .init_ack_masked = true,
  658. ++ .irqs = axp313a_regmap_irqs,
  659. ++ .num_irqs = ARRAY_SIZE(axp313a_regmap_irqs),
  660. ++ .num_regs = 1,
  661. ++};
  662. ++
  663. + static const struct regmap_irq_chip axp803_regmap_irq_chip = {
  664. + .name = "axp803",
  665. + .status_base = AXP20X_IRQ1_STATE,
  666. +@@ -751,6 +806,11 @@ static const struct mfd_cell axp152_cell
  667. + },
  668. + };
  669. +
  670. ++static struct mfd_cell axp313a_cells[] = {
  671. ++ MFD_CELL_NAME("axp20x-regulator"),
  672. ++ MFD_CELL_RES("axp313a-pek", axp313a_pek_resources),
  673. ++};
  674. ++
  675. + static const struct resource axp288_adc_resources[] = {
  676. + DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"),
  677. + };
  678. +@@ -920,8 +980,18 @@ static const struct mfd_cell axp_regulat
  679. + static int axp20x_power_off(struct sys_off_data *data)
  680. + {
  681. + struct axp20x_dev *axp20x = data->cb_data;
  682. ++ unsigned int shutdown_reg;
  683. +
  684. +- regmap_write(axp20x->regmap, AXP20X_OFF_CTRL, AXP20X_OFF);
  685. ++ switch (axp20x->variant) {
  686. ++ case AXP313A_ID:
  687. ++ shutdown_reg = AXP313A_SHUTDOWN_CTRL;
  688. ++ break;
  689. ++ default:
  690. ++ shutdown_reg = AXP20X_OFF_CTRL;
  691. ++ break;
  692. ++ }
  693. ++
  694. ++ regmap_write(axp20x->regmap, shutdown_reg, AXP20X_OFF);
  695. +
  696. + /* Give capacitors etc. time to drain to avoid kernel panic msg. */
  697. + mdelay(500);
  698. +@@ -984,6 +1054,12 @@ int axp20x_match_device(struct axp20x_de
  699. + axp20x->regmap_irq_chip = &axp288_regmap_irq_chip;
  700. + axp20x->irq_flags = IRQF_TRIGGER_LOW;
  701. + break;
  702. ++ case AXP313A_ID:
  703. ++ axp20x->nr_cells = ARRAY_SIZE(axp313a_cells);
  704. ++ axp20x->cells = axp313a_cells;
  705. ++ axp20x->regmap_cfg = &axp313a_regmap_config;
  706. ++ axp20x->regmap_irq_chip = &axp313a_regmap_irq_chip;
  707. ++ break;
  708. + case AXP803_ID:
  709. + axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
  710. + axp20x->cells = axp803_cells;
  711. +--- a/include/linux/mfd/axp20x.h
  712. ++++ b/include/linux/mfd/axp20x.h
  713. +@@ -17,6 +17,7 @@ enum axp20x_variants {
  714. + AXP221_ID,
  715. + AXP223_ID,
  716. + AXP288_ID,
  717. ++ AXP313A_ID,
  718. + AXP803_ID,
  719. + AXP806_ID,
  720. + AXP809_ID,
  721. +@@ -92,6 +93,17 @@ enum axp20x_variants {
  722. + #define AXP22X_ALDO3_V_OUT 0x2a
  723. + #define AXP22X_CHRG_CTRL3 0x35
  724. +
  725. ++#define AXP313A_ON_INDICATE 0x00
  726. ++#define AXP313A_OUTPUT_CONTROL 0x10
  727. ++#define AXP313A_DCDC1_CONRTOL 0x13
  728. ++#define AXP313A_DCDC2_CONRTOL 0x14
  729. ++#define AXP313A_DCDC3_CONRTOL 0x15
  730. ++#define AXP313A_ALDO1_CONRTOL 0x16
  731. ++#define AXP313A_DLDO1_CONRTOL 0x17
  732. ++#define AXP313A_SHUTDOWN_CTRL 0x1a
  733. ++#define AXP313A_IRQ_EN 0x20
  734. ++#define AXP313A_IRQ_STATE 0x21
  735. ++
  736. + #define AXP806_STARTUP_SRC 0x00
  737. + #define AXP806_CHIP_ID 0x03
  738. + #define AXP806_PWR_OUT_CTRL1 0x10
  739. +@@ -364,6 +376,16 @@ enum {
  740. + };
  741. +
  742. + enum {
  743. ++ AXP313A_DCDC1 = 0,
  744. ++ AXP313A_DCDC2,
  745. ++ AXP313A_DCDC3,
  746. ++ AXP313A_ALDO1,
  747. ++ AXP313A_DLDO1,
  748. ++ AXP313A_RTC_LDO,
  749. ++ AXP313A_REG_ID_MAX,
  750. ++};
  751. ++
  752. ++enum {
  753. + AXP806_DCDCA = 0,
  754. + AXP806_DCDCB,
  755. + AXP806_DCDCC,
  756. +@@ -613,6 +635,16 @@ enum axp288_irqs {
  757. + AXP288_IRQ_BC_USB_CHNG,
  758. + };
  759. +
  760. ++enum axp313a_irqs {
  761. ++ AXP313A_IRQ_DIE_TEMP_HIGH,
  762. ++ AXP313A_IRQ_DCDC2_V_LOW = 2,
  763. ++ AXP313A_IRQ_DCDC3_V_LOW,
  764. ++ AXP313A_IRQ_PEK_LONG,
  765. ++ AXP313A_IRQ_PEK_SHORT,
  766. ++ AXP313A_IRQ_PEK_FAL_EDGE,
  767. ++ AXP313A_IRQ_PEK_RIS_EDGE,
  768. ++};
  769. ++
  770. + enum axp803_irqs {
  771. + AXP803_IRQ_ACIN_OVER_V = 1,
  772. + AXP803_IRQ_ACIN_PLUGIN,
  773. diff --git a/target/linux/generic/backport-6.1/853-v6.5-regulator-axp20x-Add-support-for-AXP313a-variant.patch b/target/linux/generic/backport-6.1/853-v6.5-regulator-axp20x-Add-support-for-AXP313a-variant.patch
  774. new file mode 100644
  775. index 0000000000000..91f1b398244a5
  776. --- /dev/null
  777. +++ b/target/linux/generic/backport-6.1/853-v6.5-regulator-axp20x-Add-support-for-AXP313a-variant.patch
  778. @@ -0,0 +1,129 @@
  779. +From 60fd7eb89670d2636ac3156881acbd103c6eba6a Mon Sep 17 00:00:00 2001
  780. +From: Martin Botka <[email protected]>
  781. +Date: Wed, 24 May 2023 01:00:11 +0100
  782. +Subject: [PATCH] regulator: axp20x: Add support for AXP313a variant
  783. +
  784. +The AXP313a is your typical I2C controlled PMIC, although in a lighter
  785. +fashion compared to the other X-Powers PMICs: it has only three DCDC
  786. +rails, three LDOs, and no battery charging support.
  787. +
  788. +The AXP313a datasheet does not describe a register to change the DCDC
  789. +switching frequency, and talks of it being fixed at 3 MHz. Check that
  790. +the property allowing to change that frequency is absent from the DT,
  791. +and bail out otherwise.
  792. +
  793. +The third LDO, RTCLDO, is fixed, and cannot even be turned on or off,
  794. +programmatically. On top of that, its voltage is customisable (either
  795. +1.8V or 3.3V), which we cannot describe easily using the existing
  796. +regulator wrapper functions. This should be fixed properly, using
  797. +regulator-{min,max}-microvolt in the DT, but this requires more changes
  798. +to the code. As some other PMICs (AXP2xx, AXP803) seem to paper over the
  799. +same problem as well, we follow suit here and pretend it's a fixed 1.8V
  800. +regulator. A proper fix can follow later. The BSP code seems to ignore
  801. +this regulator altogether.
  802. +
  803. +Describe the AXP313A's voltage settings and switch registers, how the
  804. +voltages are encoded, and connect this to the MFD device via its
  805. +regulator ID.
  806. +
  807. +Signed-off-by: Martin Botka <[email protected]>
  808. +Signed-off-by: Andre Przywara <[email protected]>
  809. +Reviewed-by: Chen-Yu Tsai <[email protected]>
  810. +Reviewed-by: Mark Brown <[email protected]>
  811. +Tested-by: Shengyu Qu <[email protected]>
  812. +Link: https://lore.kernel.org/r/[email protected]
  813. +Signed-off-by: Mark Brown <[email protected]>
  814. +---
  815. + drivers/regulator/axp20x-regulator.c | 60 ++++++++++++++++++++++++++++
  816. + 1 file changed, 60 insertions(+)
  817. +
  818. +--- a/drivers/regulator/axp20x-regulator.c
  819. ++++ b/drivers/regulator/axp20x-regulator.c
  820. +@@ -134,6 +134,11 @@
  821. + #define AXP22X_PWR_OUT_DLDO4_MASK BIT_MASK(6)
  822. + #define AXP22X_PWR_OUT_ALDO3_MASK BIT_MASK(7)
  823. +
  824. ++#define AXP313A_DCDC1_NUM_VOLTAGES 107
  825. ++#define AXP313A_DCDC23_NUM_VOLTAGES 88
  826. ++#define AXP313A_DCDC_V_OUT_MASK GENMASK(6, 0)
  827. ++#define AXP313A_LDO_V_OUT_MASK GENMASK(4, 0)
  828. ++
  829. + #define AXP803_PWR_OUT_DCDC1_MASK BIT_MASK(0)
  830. + #define AXP803_PWR_OUT_DCDC2_MASK BIT_MASK(1)
  831. + #define AXP803_PWR_OUT_DCDC3_MASK BIT_MASK(2)
  832. +@@ -638,6 +643,48 @@ static const struct regulator_desc axp22
  833. + .ops = &axp20x_ops_sw,
  834. + };
  835. +
  836. ++static const struct linear_range axp313a_dcdc1_ranges[] = {
  837. ++ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  838. ++ REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
  839. ++ REGULATOR_LINEAR_RANGE(1600000, 88, 106, 100000),
  840. ++};
  841. ++
  842. ++static const struct linear_range axp313a_dcdc2_ranges[] = {
  843. ++ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  844. ++ REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
  845. ++};
  846. ++
  847. ++/*
  848. ++ * This is deviating from the datasheet. The values here are taken from the
  849. ++ * BSP driver and have been confirmed by measurements.
  850. ++ */
  851. ++static const struct linear_range axp313a_dcdc3_ranges[] = {
  852. ++ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  853. ++ REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000),
  854. ++};
  855. ++
  856. ++static const struct regulator_desc axp313a_regulators[] = {
  857. ++ AXP_DESC_RANGES(AXP313A, DCDC1, "dcdc1", "vin1",
  858. ++ axp313a_dcdc1_ranges, AXP313A_DCDC1_NUM_VOLTAGES,
  859. ++ AXP313A_DCDC1_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  860. ++ AXP313A_OUTPUT_CONTROL, BIT(0)),
  861. ++ AXP_DESC_RANGES(AXP313A, DCDC2, "dcdc2", "vin2",
  862. ++ axp313a_dcdc2_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
  863. ++ AXP313A_DCDC2_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  864. ++ AXP313A_OUTPUT_CONTROL, BIT(1)),
  865. ++ AXP_DESC_RANGES(AXP313A, DCDC3, "dcdc3", "vin3",
  866. ++ axp313a_dcdc3_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
  867. ++ AXP313A_DCDC3_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  868. ++ AXP313A_OUTPUT_CONTROL, BIT(2)),
  869. ++ AXP_DESC(AXP313A, ALDO1, "aldo1", "vin1", 500, 3500, 100,
  870. ++ AXP313A_ALDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
  871. ++ AXP313A_OUTPUT_CONTROL, BIT(3)),
  872. ++ AXP_DESC(AXP313A, DLDO1, "dldo1", "vin1", 500, 3500, 100,
  873. ++ AXP313A_DLDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
  874. ++ AXP313A_OUTPUT_CONTROL, BIT(4)),
  875. ++ AXP_DESC_FIXED(AXP313A, RTC_LDO, "rtc-ldo", "vin1", 1800),
  876. ++};
  877. ++
  878. + /* DCDC ranges shared with AXP813 */
  879. + static const struct linear_range axp803_dcdc234_ranges[] = {
  880. + REGULATOR_LINEAR_RANGE(500000,
  881. +@@ -1040,6 +1087,15 @@ static int axp20x_set_dcdc_freq(struct p
  882. + def = 3000;
  883. + step = 150;
  884. + break;
  885. ++ case AXP313A_ID:
  886. ++ /* The DCDC PWM frequency seems to be fixed to 3 MHz. */
  887. ++ if (dcdcfreq != 0) {
  888. ++ dev_err(&pdev->dev,
  889. ++ "DCDC frequency on AXP313a is fixed to 3 MHz.\n");
  890. ++ return -EINVAL;
  891. ++ }
  892. ++
  893. ++ return 0;
  894. + default:
  895. + dev_err(&pdev->dev,
  896. + "Setting DCDC frequency for unsupported AXP variant\n");
  897. +@@ -1232,6 +1288,10 @@ static int axp20x_regulator_probe(struct
  898. + drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
  899. + "x-powers,drive-vbus-en");
  900. + break;
  901. ++ case AXP313A_ID:
  902. ++ regulators = axp313a_regulators;
  903. ++ nregulators = AXP313A_REG_ID_MAX;
  904. ++ break;
  905. + case AXP803_ID:
  906. + regulators = axp803_regulators;
  907. + nregulators = AXP803_REG_ID_MAX;
  908. diff --git a/target/linux/starfive/patches-6.1/0118-driver-regulator-axp20x-Support-AXP15060-variant.patch b/target/linux/generic/backport-6.1/854-v6.5-regulator-axp20x-Add-AXP15060-support.patch
  909. similarity index 74%
  910. rename from target/linux/starfive/patches-6.1/0118-driver-regulator-axp20x-Support-AXP15060-variant.patch
  911. rename to target/linux/generic/backport-6.1/854-v6.5-regulator-axp20x-Add-AXP15060-support.patch
  912. index ccb277b3a01c7..6af09204af2e5 100644
  913. --- a/target/linux/starfive/patches-6.1/0118-driver-regulator-axp20x-Support-AXP15060-variant.patch
  914. +++ b/target/linux/generic/backport-6.1/854-v6.5-regulator-axp20x-Add-AXP15060-support.patch
  915. @@ -1,30 +1,35 @@
  916. -From 1b017f3376a5df4a2cd5a120c16723e777fc9a36 Mon Sep 17 00:00:00 2001
  917. -From: "ziv.xu" <[email protected]>
  918. -Date: Fri, 4 Aug 2023 13:55:23 +0800
  919. -Subject: [PATCH 118/122] driver: regulator: axp20x: Support AXP15060 variant.
  920. +From 9e72869d0fe12aba8cd489e485d93912b3f5c248 Mon Sep 17 00:00:00 2001
  921. +From: Shengyu Qu <[email protected]>
  922. +Date: Wed, 24 May 2023 01:00:12 +0100
  923. +Subject: [PATCH] regulator: axp20x: Add AXP15060 support
  924. -Add axp15060 variant support to axp20x
  925. +The AXP15060 is a typical I2C-controlled PMIC, seen on multiple boards
  926. +with different default register value. Current driver is tested on
  927. +Starfive Visionfive 2.
  928. -Signed-off-by: ziv.xu <[email protected]>
  929. +The RTCLDO is fixed, and cannot even be turned on or off. On top of
  930. +that, its voltage is customisable (either 1.8V or 3.3V). We pretend it's
  931. +a fixed 1.8V regulator since other AXP driver also do like this. Also,
  932. +BSP code ignores this regulator and it's not used according to VF2
  933. +schematic.
  934. +
  935. +Describe the AXP15060's voltage settings and switch registers, how the
  936. +voltages are encoded, and connect this to the MFD device via its
  937. +regulator ID.
  938. +
  939. +Signed-off-by: Shengyu Qu <[email protected]>
  940. +Signed-off-by: Andre Przywara <[email protected]>
  941. +Reviewed-by: Mark Brown <[email protected]>
  942. +Tested-by: Shengyu Qu <[email protected]>
  943. +Link: https://lore.kernel.org/r/[email protected]
  944. +Signed-off-by: Mark Brown <[email protected]>
  945. ---
  946. - drivers/regulator/axp20x-regulator.c | 291 ++++++++++++++++++++++++++-
  947. - 1 file changed, 283 insertions(+), 8 deletions(-)
  948. + drivers/regulator/axp20x-regulator.c | 232 +++++++++++++++++++++++++--
  949. + 1 file changed, 223 insertions(+), 9 deletions(-)
  950. --- a/drivers/regulator/axp20x-regulator.c
  951. +++ b/drivers/regulator/axp20x-regulator.c
  952. -@@ -134,6 +134,11 @@
  953. - #define AXP22X_PWR_OUT_DLDO4_MASK BIT_MASK(6)
  954. - #define AXP22X_PWR_OUT_ALDO3_MASK BIT_MASK(7)
  955. -
  956. -+#define AXP313A_DCDC1_NUM_VOLTAGES 107
  957. -+#define AXP313A_DCDC23_NUM_VOLTAGES 88
  958. -+#define AXP313A_DCDC_V_OUT_MASK GENMASK(6, 0)
  959. -+#define AXP313A_LDO_V_OUT_MASK GENMASK(4, 0)
  960. -+
  961. - #define AXP803_PWR_OUT_DCDC1_MASK BIT_MASK(0)
  962. - #define AXP803_PWR_OUT_DCDC2_MASK BIT_MASK(1)
  963. - #define AXP803_PWR_OUT_DCDC3_MASK BIT_MASK(2)
  964. -@@ -270,6 +275,74 @@
  965. +@@ -275,6 +275,74 @@
  966. #define AXP813_PWR_OUT_DCDC7_MASK BIT_MASK(6)
  967. @@ -99,56 +104,7 @@ Signed-off-by: ziv.xu <[email protected]>
  968. #define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg, \
  969. _vmask, _ereg, _emask, _enable_val, _disable_val) \
  970. [_family##_##_id] = { \
  971. -@@ -638,6 +711,48 @@ static const struct regulator_desc axp22
  972. - .ops = &axp20x_ops_sw,
  973. - };
  974. -
  975. -+static const struct linear_range axp313a_dcdc1_ranges[] = {
  976. -+ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  977. -+ REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
  978. -+ REGULATOR_LINEAR_RANGE(1600000, 88, 106, 100000),
  979. -+};
  980. -+
  981. -+static const struct linear_range axp313a_dcdc2_ranges[] = {
  982. -+ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  983. -+ REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000),
  984. -+};
  985. -+
  986. -+/*
  987. -+ * This is deviating from the datasheet. The values here are taken from the
  988. -+ * BSP driver and have been confirmed by measurements.
  989. -+ */
  990. -+static const struct linear_range axp313a_dcdc3_ranges[] = {
  991. -+ REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000),
  992. -+ REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000),
  993. -+};
  994. -+
  995. -+static const struct regulator_desc axp313a_regulators[] = {
  996. -+ AXP_DESC_RANGES(AXP313A, DCDC1, "dcdc1", "vin1",
  997. -+ axp313a_dcdc1_ranges, AXP313A_DCDC1_NUM_VOLTAGES,
  998. -+ AXP313A_DCDC1_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  999. -+ AXP313A_OUTPUT_CONTROL, BIT(0)),
  1000. -+ AXP_DESC_RANGES(AXP313A, DCDC2, "dcdc2", "vin2",
  1001. -+ axp313a_dcdc2_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
  1002. -+ AXP313A_DCDC2_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  1003. -+ AXP313A_OUTPUT_CONTROL, BIT(1)),
  1004. -+ AXP_DESC_RANGES(AXP313A, DCDC3, "dcdc3", "vin3",
  1005. -+ axp313a_dcdc3_ranges, AXP313A_DCDC23_NUM_VOLTAGES,
  1006. -+ AXP313A_DCDC3_CONRTOL, AXP313A_DCDC_V_OUT_MASK,
  1007. -+ AXP313A_OUTPUT_CONTROL, BIT(2)),
  1008. -+ AXP_DESC(AXP313A, ALDO1, "aldo1", "vin1", 500, 3500, 100,
  1009. -+ AXP313A_ALDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
  1010. -+ AXP313A_OUTPUT_CONTROL, BIT(3)),
  1011. -+ AXP_DESC(AXP313A, DLDO1, "dldo1", "vin1", 500, 3500, 100,
  1012. -+ AXP313A_DLDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK,
  1013. -+ AXP313A_OUTPUT_CONTROL, BIT(4)),
  1014. -+ AXP_DESC_FIXED(AXP313A, RTC_LDO, "rtc-ldo", "vin1", 1800),
  1015. -+};
  1016. -+
  1017. - /* DCDC ranges shared with AXP813 */
  1018. - static const struct linear_range axp803_dcdc234_ranges[] = {
  1019. - REGULATOR_LINEAR_RANGE(500000,
  1020. -@@ -1001,6 +1116,104 @@ static const struct regulator_desc axp81
  1021. +@@ -1048,6 +1116,104 @@ static const struct regulator_desc axp81
  1022. AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK),
  1023. };
  1024. @@ -253,24 +209,20 @@ Signed-off-by: ziv.xu <[email protected]>
  1025. static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
  1026. {
  1027. struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
  1028. -@@ -1040,6 +1253,16 @@ static int axp20x_set_dcdc_freq(struct p
  1029. - def = 3000;
  1030. +@@ -1088,10 +1254,11 @@ static int axp20x_set_dcdc_freq(struct p
  1031. step = 150;
  1032. break;
  1033. -+ case AXP313A_ID:
  1034. + case AXP313A_ID:
  1035. + case AXP15060_ID:
  1036. -+ /* The DCDC PWM frequency seems to be fixed to 3 MHz. */
  1037. -+ if (dcdcfreq != 0) {
  1038. -+ dev_err(&pdev->dev,
  1039. + /* The DCDC PWM frequency seems to be fixed to 3 MHz. */
  1040. + if (dcdcfreq != 0) {
  1041. + dev_err(&pdev->dev,
  1042. +- "DCDC frequency on AXP313a is fixed to 3 MHz.\n");
  1043. + "DCDC frequency on this PMIC is fixed to 3 MHz.\n");
  1044. -+ return -EINVAL;
  1045. -+ }
  1046. -+
  1047. -+ return 0;
  1048. - default:
  1049. - dev_err(&pdev->dev,
  1050. - "Setting DCDC frequency for unsupported AXP variant\n");
  1051. -@@ -1145,6 +1368,15 @@ static int axp20x_set_dcdc_workmode(stru
  1052. + return -EINVAL;
  1053. + }
  1054. +
  1055. +@@ -1201,6 +1368,15 @@ static int axp20x_set_dcdc_workmode(stru
  1056. workmode <<= id - AXP813_DCDC1;
  1057. break;
  1058. @@ -286,7 +238,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1059. default:
  1060. /* should not happen */
  1061. WARN_ON(1);
  1062. -@@ -1164,7 +1396,7 @@ static bool axp20x_is_polyphase_slave(st
  1063. +@@ -1220,7 +1396,7 @@ static bool axp20x_is_polyphase_slave(st
  1064. /*
  1065. * Currently in our supported AXP variants, only AXP803, AXP806,
  1066. @@ -295,7 +247,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1067. */
  1068. switch (axp20x->variant) {
  1069. case AXP803_ID:
  1070. -@@ -1196,6 +1428,17 @@ static bool axp20x_is_polyphase_slave(st
  1071. +@@ -1252,6 +1428,17 @@ static bool axp20x_is_polyphase_slave(st
  1072. }
  1073. break;
  1074. @@ -313,7 +265,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1075. default:
  1076. return false;
  1077. }
  1078. -@@ -1217,6 +1460,7 @@ static int axp20x_regulator_probe(struct
  1079. +@@ -1273,6 +1460,7 @@ static int axp20x_regulator_probe(struct
  1080. u32 workmode;
  1081. const char *dcdc1_name = axp22x_regulators[AXP22X_DCDC1].name;
  1082. const char *dcdc5_name = axp22x_regulators[AXP22X_DCDC5].name;
  1083. @@ -321,18 +273,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1084. bool drivevbus = false;
  1085. switch (axp20x->variant) {
  1086. -@@ -1232,6 +1476,10 @@ static int axp20x_regulator_probe(struct
  1087. - drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
  1088. - "x-powers,drive-vbus-en");
  1089. - break;
  1090. -+ case AXP313A_ID:
  1091. -+ regulators = axp313a_regulators;
  1092. -+ nregulators = AXP313A_REG_ID_MAX;
  1093. -+ break;
  1094. - case AXP803_ID:
  1095. - regulators = axp803_regulators;
  1096. - nregulators = AXP803_REG_ID_MAX;
  1097. -@@ -1252,6 +1500,10 @@ static int axp20x_regulator_probe(struct
  1098. +@@ -1312,6 +1500,10 @@ static int axp20x_regulator_probe(struct
  1099. drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
  1100. "x-powers,drive-vbus-en");
  1101. break;
  1102. @@ -343,7 +284,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1103. default:
  1104. dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
  1105. axp20x->variant);
  1106. -@@ -1278,8 +1530,9 @@ static int axp20x_regulator_probe(struct
  1107. +@@ -1338,8 +1530,9 @@ static int axp20x_regulator_probe(struct
  1108. continue;
  1109. /*
  1110. @@ -355,7 +296,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1111. *
  1112. * We always register the regulators in proper sequence,
  1113. * so the supply names are correctly read. See the last
  1114. -@@ -1288,7 +1541,8 @@ static int axp20x_regulator_probe(struct
  1115. +@@ -1348,7 +1541,8 @@ static int axp20x_regulator_probe(struct
  1116. */
  1117. if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) ||
  1118. (regulators == axp803_regulators && i == AXP803_DC1SW) ||
  1119. @@ -365,7 +306,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1120. new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
  1121. GFP_KERNEL);
  1122. if (!new_desc)
  1123. -@@ -1300,7 +1554,8 @@ static int axp20x_regulator_probe(struct
  1124. +@@ -1360,7 +1554,8 @@ static int axp20x_regulator_probe(struct
  1125. }
  1126. if ((regulators == axp22x_regulators && i == AXP22X_DC5LDO) ||
  1127. @@ -375,7 +316,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1128. new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
  1129. GFP_KERNEL);
  1130. if (!new_desc)
  1131. -@@ -1311,6 +1566,18 @@ static int axp20x_regulator_probe(struct
  1132. +@@ -1371,6 +1566,18 @@ static int axp20x_regulator_probe(struct
  1133. desc = new_desc;
  1134. }
  1135. @@ -394,7 +335,7 @@ Signed-off-by: ziv.xu <[email protected]>
  1136. rdev = devm_regulator_register(&pdev->dev, desc, &config);
  1137. if (IS_ERR(rdev)) {
  1138. dev_err(&pdev->dev, "Failed to register %s\n",
  1139. -@@ -1329,19 +1596,26 @@ static int axp20x_regulator_probe(struct
  1140. +@@ -1389,19 +1596,26 @@ static int axp20x_regulator_probe(struct
  1141. }
  1142. /*
  1143. @@ -424,11 +365,3 @@ Signed-off-by: ziv.xu <[email protected]>
  1144. }
  1145. if (drivevbus) {
  1146. -@@ -1364,6 +1638,7 @@ static struct platform_driver axp20x_reg
  1147. - .probe = axp20x_regulator_probe,
  1148. - .driver = {
  1149. - .name = "axp20x-regulator",
  1150. -+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  1151. - },
  1152. - };
  1153. -
  1154. diff --git a/target/linux/generic/backport-6.1/855-v6.5-mfd-axp20x-Add-support-for-AXP192.patch b/target/linux/generic/backport-6.1/855-v6.5-mfd-axp20x-Add-support-for-AXP192.patch
  1155. new file mode 100644
  1156. index 0000000000000..20a26db3e621a
  1157. --- /dev/null
  1158. +++ b/target/linux/generic/backport-6.1/855-v6.5-mfd-axp20x-Add-support-for-AXP192.patch
  1159. @@ -0,0 +1,383 @@
  1160. +From 63eeabbc9dbddd7381409feccd9082e5ffabfe59 Mon Sep 17 00:00:00 2001
  1161. +From: Aidan MacDonald <[email protected]>
  1162. +Date: Thu, 11 May 2023 10:26:08 +0100
  1163. +Subject: [PATCH] mfd: axp20x: Add support for AXP192
  1164. +
  1165. +The AXP192 PMIC is similar to the AXP202/AXP209, but with different
  1166. +regulators, additional GPIOs, and a different IRQ register layout.
  1167. +
  1168. +Signed-off-by: Aidan MacDonald <[email protected]>
  1169. +Link: https://lore.kernel.org/r/[email protected]
  1170. +Signed-off-by: Lee Jones <[email protected]>
  1171. +---
  1172. + drivers/mfd/axp20x-i2c.c | 2 +
  1173. + drivers/mfd/axp20x.c | 141 +++++++++++++++++++++++++++++++++++++
  1174. + include/linux/mfd/axp20x.h | 84 ++++++++++++++++++++++
  1175. + 3 files changed, 227 insertions(+)
  1176. +
  1177. +--- a/drivers/mfd/axp20x-i2c.c
  1178. ++++ b/drivers/mfd/axp20x-i2c.c
  1179. +@@ -60,6 +60,7 @@ static void axp20x_i2c_remove(struct i2c
  1180. + #ifdef CONFIG_OF
  1181. + static const struct of_device_id axp20x_i2c_of_match[] = {
  1182. + { .compatible = "x-powers,axp152", .data = (void *)AXP152_ID },
  1183. ++ { .compatible = "x-powers,axp192", .data = (void *)AXP192_ID },
  1184. + { .compatible = "x-powers,axp202", .data = (void *)AXP202_ID },
  1185. + { .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
  1186. + { .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
  1187. +@@ -75,6 +76,7 @@ MODULE_DEVICE_TABLE(of, axp20x_i2c_of_ma
  1188. +
  1189. + static const struct i2c_device_id axp20x_i2c_id[] = {
  1190. + { "axp152", 0 },
  1191. ++ { "axp192", 0 },
  1192. + { "axp202", 0 },
  1193. + { "axp209", 0 },
  1194. + { "axp221", 0 },
  1195. +--- a/drivers/mfd/axp20x.c
  1196. ++++ b/drivers/mfd/axp20x.c
  1197. +@@ -34,6 +34,7 @@
  1198. +
  1199. + static const char * const axp20x_model_names[] = {
  1200. + "AXP152",
  1201. ++ "AXP192",
  1202. + "AXP202",
  1203. + "AXP209",
  1204. + "AXP221",
  1205. +@@ -94,6 +95,35 @@ static const struct regmap_access_table
  1206. + .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
  1207. + };
  1208. +
  1209. ++static const struct regmap_range axp192_writeable_ranges[] = {
  1210. ++ regmap_reg_range(AXP192_DATACACHE(0), AXP192_DATACACHE(5)),
  1211. ++ regmap_reg_range(AXP192_PWR_OUT_CTRL, AXP192_IRQ5_STATE),
  1212. ++ regmap_reg_range(AXP20X_DCDC_MODE, AXP192_N_RSTO_CTRL),
  1213. ++ regmap_reg_range(AXP20X_CC_CTRL, AXP20X_CC_CTRL),
  1214. ++};
  1215. ++
  1216. ++static const struct regmap_range axp192_volatile_ranges[] = {
  1217. ++ regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP192_USB_OTG_STATUS),
  1218. ++ regmap_reg_range(AXP192_IRQ1_STATE, AXP192_IRQ4_STATE),
  1219. ++ regmap_reg_range(AXP192_IRQ5_STATE, AXP192_IRQ5_STATE),
  1220. ++ regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L),
  1221. ++ regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL),
  1222. ++ regmap_reg_range(AXP192_GPIO2_0_STATE, AXP192_GPIO2_0_STATE),
  1223. ++ regmap_reg_range(AXP192_GPIO4_3_STATE, AXP192_GPIO4_3_STATE),
  1224. ++ regmap_reg_range(AXP192_N_RSTO_CTRL, AXP192_N_RSTO_CTRL),
  1225. ++ regmap_reg_range(AXP20X_CHRG_CC_31_24, AXP20X_CC_CTRL),
  1226. ++};
  1227. ++
  1228. ++static const struct regmap_access_table axp192_writeable_table = {
  1229. ++ .yes_ranges = axp192_writeable_ranges,
  1230. ++ .n_yes_ranges = ARRAY_SIZE(axp192_writeable_ranges),
  1231. ++};
  1232. ++
  1233. ++static const struct regmap_access_table axp192_volatile_table = {
  1234. ++ .yes_ranges = axp192_volatile_ranges,
  1235. ++ .n_yes_ranges = ARRAY_SIZE(axp192_volatile_ranges),
  1236. ++};
  1237. ++
  1238. + /* AXP22x ranges are shared with the AXP809, as they cover the same range */
  1239. + static const struct regmap_range axp22x_writeable_ranges[] = {
  1240. + regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
  1241. +@@ -219,6 +249,19 @@ static const struct resource axp152_pek_
  1242. + DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1243. + };
  1244. +
  1245. ++static const struct resource axp192_ac_power_supply_resources[] = {
  1246. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
  1247. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
  1248. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
  1249. ++};
  1250. ++
  1251. ++static const struct resource axp192_usb_power_supply_resources[] = {
  1252. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
  1253. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
  1254. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_VALID, "VBUS_VALID"),
  1255. ++ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
  1256. ++};
  1257. ++
  1258. + static const struct resource axp20x_ac_power_supply_resources[] = {
  1259. + DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
  1260. + DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
  1261. +@@ -301,6 +344,15 @@ static const struct regmap_config axp152
  1262. + .cache_type = REGCACHE_RBTREE,
  1263. + };
  1264. +
  1265. ++static const struct regmap_config axp192_regmap_config = {
  1266. ++ .reg_bits = 8,
  1267. ++ .val_bits = 8,
  1268. ++ .wr_table = &axp192_writeable_table,
  1269. ++ .volatile_table = &axp192_volatile_table,
  1270. ++ .max_register = AXP20X_CC_CTRL,
  1271. ++ .cache_type = REGCACHE_RBTREE,
  1272. ++};
  1273. ++
  1274. + static const struct regmap_config axp20x_regmap_config = {
  1275. + .reg_bits = 8,
  1276. + .val_bits = 8,
  1277. +@@ -378,6 +430,42 @@ static const struct regmap_irq axp152_re
  1278. + INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT, 2, 0),
  1279. + };
  1280. +
  1281. ++static const struct regmap_irq axp192_regmap_irqs[] = {
  1282. ++ INIT_REGMAP_IRQ(AXP192, ACIN_OVER_V, 0, 7),
  1283. ++ INIT_REGMAP_IRQ(AXP192, ACIN_PLUGIN, 0, 6),
  1284. ++ INIT_REGMAP_IRQ(AXP192, ACIN_REMOVAL, 0, 5),
  1285. ++ INIT_REGMAP_IRQ(AXP192, VBUS_OVER_V, 0, 4),
  1286. ++ INIT_REGMAP_IRQ(AXP192, VBUS_PLUGIN, 0, 3),
  1287. ++ INIT_REGMAP_IRQ(AXP192, VBUS_REMOVAL, 0, 2),
  1288. ++ INIT_REGMAP_IRQ(AXP192, VBUS_V_LOW, 0, 1),
  1289. ++ INIT_REGMAP_IRQ(AXP192, BATT_PLUGIN, 1, 7),
  1290. ++ INIT_REGMAP_IRQ(AXP192, BATT_REMOVAL, 1, 6),
  1291. ++ INIT_REGMAP_IRQ(AXP192, BATT_ENT_ACT_MODE, 1, 5),
  1292. ++ INIT_REGMAP_IRQ(AXP192, BATT_EXIT_ACT_MODE, 1, 4),
  1293. ++ INIT_REGMAP_IRQ(AXP192, CHARG, 1, 3),
  1294. ++ INIT_REGMAP_IRQ(AXP192, CHARG_DONE, 1, 2),
  1295. ++ INIT_REGMAP_IRQ(AXP192, BATT_TEMP_HIGH, 1, 1),
  1296. ++ INIT_REGMAP_IRQ(AXP192, BATT_TEMP_LOW, 1, 0),
  1297. ++ INIT_REGMAP_IRQ(AXP192, DIE_TEMP_HIGH, 2, 7),
  1298. ++ INIT_REGMAP_IRQ(AXP192, CHARG_I_LOW, 2, 6),
  1299. ++ INIT_REGMAP_IRQ(AXP192, DCDC1_V_LONG, 2, 5),
  1300. ++ INIT_REGMAP_IRQ(AXP192, DCDC2_V_LONG, 2, 4),
  1301. ++ INIT_REGMAP_IRQ(AXP192, DCDC3_V_LONG, 2, 3),
  1302. ++ INIT_REGMAP_IRQ(AXP192, PEK_SHORT, 2, 1),
  1303. ++ INIT_REGMAP_IRQ(AXP192, PEK_LONG, 2, 0),
  1304. ++ INIT_REGMAP_IRQ(AXP192, N_OE_PWR_ON, 3, 7),
  1305. ++ INIT_REGMAP_IRQ(AXP192, N_OE_PWR_OFF, 3, 6),
  1306. ++ INIT_REGMAP_IRQ(AXP192, VBUS_VALID, 3, 5),
  1307. ++ INIT_REGMAP_IRQ(AXP192, VBUS_NOT_VALID, 3, 4),
  1308. ++ INIT_REGMAP_IRQ(AXP192, VBUS_SESS_VALID, 3, 3),
  1309. ++ INIT_REGMAP_IRQ(AXP192, VBUS_SESS_END, 3, 2),
  1310. ++ INIT_REGMAP_IRQ(AXP192, LOW_PWR_LVL, 3, 0),
  1311. ++ INIT_REGMAP_IRQ(AXP192, TIMER, 4, 7),
  1312. ++ INIT_REGMAP_IRQ(AXP192, GPIO2_INPUT, 4, 2),
  1313. ++ INIT_REGMAP_IRQ(AXP192, GPIO1_INPUT, 4, 1),
  1314. ++ INIT_REGMAP_IRQ(AXP192, GPIO0_INPUT, 4, 0),
  1315. ++};
  1316. ++
  1317. + static const struct regmap_irq axp20x_regmap_irqs[] = {
  1318. + INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7),
  1319. + INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6),
  1320. +@@ -615,6 +703,32 @@ static const struct regmap_irq_chip axp1
  1321. + .num_regs = 3,
  1322. + };
  1323. +
  1324. ++static unsigned int axp192_get_irq_reg(struct regmap_irq_chip_data *data,
  1325. ++ unsigned int base, int index)
  1326. ++{
  1327. ++ /* linear mapping for IRQ1 to IRQ4 */
  1328. ++ if (index < 4)
  1329. ++ return base + index;
  1330. ++
  1331. ++ /* handle IRQ5 separately */
  1332. ++ if (base == AXP192_IRQ1_EN)
  1333. ++ return AXP192_IRQ5_EN;
  1334. ++
  1335. ++ return AXP192_IRQ5_STATE;
  1336. ++}
  1337. ++
  1338. ++static const struct regmap_irq_chip axp192_regmap_irq_chip = {
  1339. ++ .name = "axp192_irq_chip",
  1340. ++ .status_base = AXP192_IRQ1_STATE,
  1341. ++ .ack_base = AXP192_IRQ1_STATE,
  1342. ++ .unmask_base = AXP192_IRQ1_EN,
  1343. ++ .init_ack_masked = true,
  1344. ++ .irqs = axp192_regmap_irqs,
  1345. ++ .num_irqs = ARRAY_SIZE(axp192_regmap_irqs),
  1346. ++ .num_regs = 5,
  1347. ++ .get_irq_reg = axp192_get_irq_reg,
  1348. ++};
  1349. ++
  1350. + static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
  1351. + .name = "axp20x_irq_chip",
  1352. + .status_base = AXP20X_IRQ1_STATE,
  1353. +@@ -711,6 +825,27 @@ static const struct regmap_irq_chip axp1
  1354. + .num_regs = 2,
  1355. + };
  1356. +
  1357. ++static const struct mfd_cell axp192_cells[] = {
  1358. ++ {
  1359. ++ .name = "axp192-adc",
  1360. ++ .of_compatible = "x-powers,axp192-adc",
  1361. ++ }, {
  1362. ++ .name = "axp20x-battery-power-supply",
  1363. ++ .of_compatible = "x-powers,axp192-battery-power-supply",
  1364. ++ }, {
  1365. ++ .name = "axp20x-ac-power-supply",
  1366. ++ .of_compatible = "x-powers,axp202-ac-power-supply",
  1367. ++ .num_resources = ARRAY_SIZE(axp192_ac_power_supply_resources),
  1368. ++ .resources = axp192_ac_power_supply_resources,
  1369. ++ }, {
  1370. ++ .name = "axp20x-usb-power-supply",
  1371. ++ .of_compatible = "x-powers,axp192-usb-power-supply",
  1372. ++ .num_resources = ARRAY_SIZE(axp192_usb_power_supply_resources),
  1373. ++ .resources = axp192_usb_power_supply_resources,
  1374. ++ },
  1375. ++ { .name = "axp20x-regulator" },
  1376. ++};
  1377. ++
  1378. + static const struct mfd_cell axp20x_cells[] = {
  1379. + {
  1380. + .name = "axp20x-gpio",
  1381. +@@ -1028,6 +1163,12 @@ int axp20x_match_device(struct axp20x_de
  1382. + axp20x->regmap_cfg = &axp152_regmap_config;
  1383. + axp20x->regmap_irq_chip = &axp152_regmap_irq_chip;
  1384. + break;
  1385. ++ case AXP192_ID:
  1386. ++ axp20x->nr_cells = ARRAY_SIZE(axp192_cells);
  1387. ++ axp20x->cells = axp192_cells;
  1388. ++ axp20x->regmap_cfg = &axp192_regmap_config;
  1389. ++ axp20x->regmap_irq_chip = &axp192_regmap_irq_chip;
  1390. ++ break;
  1391. + case AXP202_ID:
  1392. + case AXP209_ID:
  1393. + axp20x->nr_cells = ARRAY_SIZE(axp20x_cells);
  1394. +--- a/include/linux/mfd/axp20x.h
  1395. ++++ b/include/linux/mfd/axp20x.h
  1396. +@@ -12,6 +12,7 @@
  1397. +
  1398. + enum axp20x_variants {
  1399. + AXP152_ID = 0,
  1400. ++ AXP192_ID,
  1401. + AXP202_ID,
  1402. + AXP209_ID,
  1403. + AXP221_ID,
  1404. +@@ -26,6 +27,7 @@ enum axp20x_variants {
  1405. + NR_AXP20X_VARIANTS,
  1406. + };
  1407. +
  1408. ++#define AXP192_DATACACHE(m) (0x06 + (m))
  1409. + #define AXP20X_DATACACHE(m) (0x04 + (m))
  1410. +
  1411. + /* Power supply */
  1412. +@@ -47,6 +49,13 @@ enum axp20x_variants {
  1413. + #define AXP152_DCDC_FREQ 0x37
  1414. + #define AXP152_DCDC_MODE 0x80
  1415. +
  1416. ++#define AXP192_USB_OTG_STATUS 0x04
  1417. ++#define AXP192_PWR_OUT_CTRL 0x12
  1418. ++#define AXP192_DCDC2_V_OUT 0x23
  1419. ++#define AXP192_DCDC1_V_OUT 0x26
  1420. ++#define AXP192_DCDC3_V_OUT 0x27
  1421. ++#define AXP192_LDO2_3_V_OUT 0x28
  1422. ++
  1423. + #define AXP20X_PWR_INPUT_STATUS 0x00
  1424. + #define AXP20X_PWR_OP_MODE 0x01
  1425. + #define AXP20X_USB_OTG_STATUS 0x02
  1426. +@@ -185,6 +194,17 @@ enum axp20x_variants {
  1427. + #define AXP152_IRQ2_STATE 0x49
  1428. + #define AXP152_IRQ3_STATE 0x4a
  1429. +
  1430. ++#define AXP192_IRQ1_EN 0x40
  1431. ++#define AXP192_IRQ2_EN 0x41
  1432. ++#define AXP192_IRQ3_EN 0x42
  1433. ++#define AXP192_IRQ4_EN 0x43
  1434. ++#define AXP192_IRQ1_STATE 0x44
  1435. ++#define AXP192_IRQ2_STATE 0x45
  1436. ++#define AXP192_IRQ3_STATE 0x46
  1437. ++#define AXP192_IRQ4_STATE 0x47
  1438. ++#define AXP192_IRQ5_EN 0x4a
  1439. ++#define AXP192_IRQ5_STATE 0x4d
  1440. ++
  1441. + #define AXP20X_IRQ1_EN 0x40
  1442. + #define AXP20X_IRQ2_EN 0x41
  1443. + #define AXP20X_IRQ3_EN 0x42
  1444. +@@ -204,6 +224,11 @@ enum axp20x_variants {
  1445. + #define AXP15060_IRQ2_STATE 0x49
  1446. +
  1447. + /* ADC */
  1448. ++#define AXP192_GPIO2_V_ADC_H 0x68
  1449. ++#define AXP192_GPIO2_V_ADC_L 0x69
  1450. ++#define AXP192_GPIO3_V_ADC_H 0x6a
  1451. ++#define AXP192_GPIO3_V_ADC_L 0x6b
  1452. ++
  1453. + #define AXP20X_ACIN_V_ADC_H 0x56
  1454. + #define AXP20X_ACIN_V_ADC_L 0x57
  1455. + #define AXP20X_ACIN_I_ADC_H 0x58
  1456. +@@ -233,6 +258,8 @@ enum axp20x_variants {
  1457. + #define AXP20X_IPSOUT_V_HIGH_L 0x7f
  1458. +
  1459. + /* Power supply */
  1460. ++#define AXP192_GPIO30_IN_RANGE 0x85
  1461. ++
  1462. + #define AXP20X_DCDC_MODE 0x80
  1463. + #define AXP20X_ADC_EN1 0x82
  1464. + #define AXP20X_ADC_EN2 0x83
  1465. +@@ -261,6 +288,16 @@ enum axp20x_variants {
  1466. + #define AXP152_PWM1_FREQ_Y 0x9c
  1467. + #define AXP152_PWM1_DUTY_CYCLE 0x9d
  1468. +
  1469. ++#define AXP192_GPIO0_CTRL 0x90
  1470. ++#define AXP192_LDO_IO0_V_OUT 0x91
  1471. ++#define AXP192_GPIO1_CTRL 0x92
  1472. ++#define AXP192_GPIO2_CTRL 0x93
  1473. ++#define AXP192_GPIO2_0_STATE 0x94
  1474. ++#define AXP192_GPIO4_3_CTRL 0x95
  1475. ++#define AXP192_GPIO4_3_STATE 0x96
  1476. ++#define AXP192_GPIO2_0_PULL 0x97
  1477. ++#define AXP192_N_RSTO_CTRL 0x9e
  1478. ++
  1479. + #define AXP20X_GPIO0_CTRL 0x90
  1480. + #define AXP20X_LDO5_V_OUT 0x91
  1481. + #define AXP20X_GPIO1_CTRL 0x92
  1482. +@@ -341,6 +378,17 @@ enum axp20x_variants {
  1483. +
  1484. + /* Regulators IDs */
  1485. + enum {
  1486. ++ AXP192_DCDC1 = 0,
  1487. ++ AXP192_DCDC2,
  1488. ++ AXP192_DCDC3,
  1489. ++ AXP192_LDO1,
  1490. ++ AXP192_LDO2,
  1491. ++ AXP192_LDO3,
  1492. ++ AXP192_LDO_IO0,
  1493. ++ AXP192_REG_ID_MAX
  1494. ++};
  1495. ++
  1496. ++enum {
  1497. + AXP20X_LDO1 = 0,
  1498. + AXP20X_LDO2,
  1499. + AXP20X_LDO3,
  1500. +@@ -530,6 +578,42 @@ enum {
  1501. + AXP152_IRQ_GPIO0_INPUT,
  1502. + };
  1503. +
  1504. ++enum axp192_irqs {
  1505. ++ AXP192_IRQ_ACIN_OVER_V = 1,
  1506. ++ AXP192_IRQ_ACIN_PLUGIN,
  1507. ++ AXP192_IRQ_ACIN_REMOVAL,
  1508. ++ AXP192_IRQ_VBUS_OVER_V,
  1509. ++ AXP192_IRQ_VBUS_PLUGIN,
  1510. ++ AXP192_IRQ_VBUS_REMOVAL,
  1511. ++ AXP192_IRQ_VBUS_V_LOW,
  1512. ++ AXP192_IRQ_BATT_PLUGIN,
  1513. ++ AXP192_IRQ_BATT_REMOVAL,
  1514. ++ AXP192_IRQ_BATT_ENT_ACT_MODE,
  1515. ++ AXP192_IRQ_BATT_EXIT_ACT_MODE,
  1516. ++ AXP192_IRQ_CHARG,
  1517. ++ AXP192_IRQ_CHARG_DONE,
  1518. ++ AXP192_IRQ_BATT_TEMP_HIGH,
  1519. ++ AXP192_IRQ_BATT_TEMP_LOW,
  1520. ++ AXP192_IRQ_DIE_TEMP_HIGH,
  1521. ++ AXP192_IRQ_CHARG_I_LOW,
  1522. ++ AXP192_IRQ_DCDC1_V_LONG,
  1523. ++ AXP192_IRQ_DCDC2_V_LONG,
  1524. ++ AXP192_IRQ_DCDC3_V_LONG,
  1525. ++ AXP192_IRQ_PEK_SHORT = 22,
  1526. ++ AXP192_IRQ_PEK_LONG,
  1527. ++ AXP192_IRQ_N_OE_PWR_ON,
  1528. ++ AXP192_IRQ_N_OE_PWR_OFF,
  1529. ++ AXP192_IRQ_VBUS_VALID,
  1530. ++ AXP192_IRQ_VBUS_NOT_VALID,
  1531. ++ AXP192_IRQ_VBUS_SESS_VALID,
  1532. ++ AXP192_IRQ_VBUS_SESS_END,
  1533. ++ AXP192_IRQ_LOW_PWR_LVL = 31,
  1534. ++ AXP192_IRQ_TIMER,
  1535. ++ AXP192_IRQ_GPIO2_INPUT = 37,
  1536. ++ AXP192_IRQ_GPIO1_INPUT,
  1537. ++ AXP192_IRQ_GPIO0_INPUT,
  1538. ++};
  1539. ++
  1540. + enum {
  1541. + AXP20X_IRQ_ACIN_OVER_V = 1,
  1542. + AXP20X_IRQ_ACIN_PLUGIN,
  1543. diff --git a/target/linux/starfive/patches-6.1/0117-driver-mfd-axp20x-Add-support-for-AXP15060.patch b/target/linux/starfive/patches-6.1/0117-driver-mfd-axp20x-Add-support-for-AXP15060.patch
  1544. deleted file mode 100644
  1545. index 18ad298065f2d..0000000000000
  1546. --- a/target/linux/starfive/patches-6.1/0117-driver-mfd-axp20x-Add-support-for-AXP15060.patch
  1547. +++ /dev/null
  1548. @@ -1,1014 +0,0 @@
  1549. -From e62161318f2fe3e396fc31c50d210e99bec83021 Mon Sep 17 00:00:00 2001
  1550. -From: "ziv.xu" <[email protected]>
  1551. -Date: Fri, 4 Aug 2023 13:53:10 +0800
  1552. -Subject: [PATCH 117/122] driver: mfd: axp20x: Add support for AXP15060
  1553. -
  1554. -axp20x add support for AXP15060
  1555. -
  1556. -Signed-off-by: ziv.xu <[email protected]>
  1557. ----
  1558. - drivers/mfd/axp20x-i2c.c | 2 +
  1559. - drivers/mfd/axp20x.c | 373 ++++++++++++++++++++++++++++++++++---
  1560. - include/linux/mfd/axp20x.h | 218 +++++++++++++++++++++-
  1561. - 3 files changed, 557 insertions(+), 36 deletions(-)
  1562. -
  1563. ---- a/drivers/mfd/axp20x-i2c.c
  1564. -+++ b/drivers/mfd/axp20x-i2c.c
  1565. -@@ -66,6 +66,7 @@ static const struct of_device_id axp20x_
  1566. - { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
  1567. - { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
  1568. - { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
  1569. -+ { .compatible = "x-powers,axp15060", .data = (void *)AXP15060_ID },
  1570. - { },
  1571. - };
  1572. - MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match);
  1573. -@@ -79,6 +80,7 @@ static const struct i2c_device_id axp20x
  1574. - { "axp223", 0 },
  1575. - { "axp803", 0 },
  1576. - { "axp806", 0 },
  1577. -+ { "axp15060", 0 },
  1578. - { },
  1579. - };
  1580. - MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
  1581. ---- a/drivers/mfd/axp20x.c
  1582. -+++ b/drivers/mfd/axp20x.c
  1583. -@@ -23,7 +23,7 @@
  1584. - #include <linux/mfd/core.h>
  1585. - #include <linux/module.h>
  1586. - #include <linux/of_device.h>
  1587. --#include <linux/pm_runtime.h>
  1588. -+#include <linux/reboot.h>
  1589. - #include <linux/regmap.h>
  1590. - #include <linux/regulator/consumer.h>
  1591. -
  1592. -@@ -34,15 +34,18 @@
  1593. -
  1594. - static const char * const axp20x_model_names[] = {
  1595. - "AXP152",
  1596. -+ "AXP192",
  1597. - "AXP202",
  1598. - "AXP209",
  1599. - "AXP221",
  1600. - "AXP223",
  1601. - "AXP288",
  1602. -+ "AXP313a",
  1603. - "AXP803",
  1604. - "AXP806",
  1605. - "AXP809",
  1606. - "AXP813",
  1607. -+ "AXP15060",
  1608. - };
  1609. -
  1610. - static const struct regmap_range axp152_writeable_ranges[] = {
  1611. -@@ -92,6 +95,35 @@ static const struct regmap_access_table
  1612. - .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
  1613. - };
  1614. -
  1615. -+static const struct regmap_range axp192_writeable_ranges[] = {
  1616. -+ regmap_reg_range(AXP192_DATACACHE(0), AXP192_DATACACHE(5)),
  1617. -+ regmap_reg_range(AXP192_PWR_OUT_CTRL, AXP192_IRQ5_STATE),
  1618. -+ regmap_reg_range(AXP20X_DCDC_MODE, AXP192_N_RSTO_CTRL),
  1619. -+ regmap_reg_range(AXP20X_CC_CTRL, AXP20X_CC_CTRL),
  1620. -+};
  1621. -+
  1622. -+static const struct regmap_range axp192_volatile_ranges[] = {
  1623. -+ regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP192_USB_OTG_STATUS),
  1624. -+ regmap_reg_range(AXP192_IRQ1_STATE, AXP192_IRQ4_STATE),
  1625. -+ regmap_reg_range(AXP192_IRQ5_STATE, AXP192_IRQ5_STATE),
  1626. -+ regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L),
  1627. -+ regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL),
  1628. -+ regmap_reg_range(AXP192_GPIO2_0_STATE, AXP192_GPIO2_0_STATE),
  1629. -+ regmap_reg_range(AXP192_GPIO4_3_STATE, AXP192_GPIO4_3_STATE),
  1630. -+ regmap_reg_range(AXP192_N_RSTO_CTRL, AXP192_N_RSTO_CTRL),
  1631. -+ regmap_reg_range(AXP20X_CHRG_CC_31_24, AXP20X_CC_CTRL),
  1632. -+};
  1633. -+
  1634. -+static const struct regmap_access_table axp192_writeable_table = {
  1635. -+ .yes_ranges = axp192_writeable_ranges,
  1636. -+ .n_yes_ranges = ARRAY_SIZE(axp192_writeable_ranges),
  1637. -+};
  1638. -+
  1639. -+static const struct regmap_access_table axp192_volatile_table = {
  1640. -+ .yes_ranges = axp192_volatile_ranges,
  1641. -+ .n_yes_ranges = ARRAY_SIZE(axp192_volatile_ranges),
  1642. -+};
  1643. -+
  1644. - /* AXP22x ranges are shared with the AXP809, as they cover the same range */
  1645. - static const struct regmap_range axp22x_writeable_ranges[] = {
  1646. - regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
  1647. -@@ -119,6 +151,7 @@ static const struct regmap_access_table
  1648. -
  1649. - /* AXP288 ranges are shared with the AXP803, as they cover the same range */
  1650. - static const struct regmap_range axp288_writeable_ranges[] = {
  1651. -+ regmap_reg_range(AXP288_POWER_REASON, AXP288_POWER_REASON),
  1652. - regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
  1653. - regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
  1654. - };
  1655. -@@ -154,6 +187,25 @@ static const struct regmap_range axp806_
  1656. - regmap_reg_range(AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT),
  1657. - };
  1658. -
  1659. -+static const struct regmap_range axp313a_writeable_ranges[] = {
  1660. -+ regmap_reg_range(AXP313A_ON_INDICATE, AXP313A_IRQ_STATE),
  1661. -+};
  1662. -+
  1663. -+static const struct regmap_range axp313a_volatile_ranges[] = {
  1664. -+ regmap_reg_range(AXP313A_SHUTDOWN_CTRL, AXP313A_SHUTDOWN_CTRL),
  1665. -+ regmap_reg_range(AXP313A_IRQ_STATE, AXP313A_IRQ_STATE),
  1666. -+};
  1667. -+
  1668. -+static const struct regmap_access_table axp313a_writeable_table = {
  1669. -+ .yes_ranges = axp313a_writeable_ranges,
  1670. -+ .n_yes_ranges = ARRAY_SIZE(axp313a_writeable_ranges),
  1671. -+};
  1672. -+
  1673. -+static const struct regmap_access_table axp313a_volatile_table = {
  1674. -+ .yes_ranges = axp313a_volatile_ranges,
  1675. -+ .n_yes_ranges = ARRAY_SIZE(axp313a_volatile_ranges),
  1676. -+};
  1677. -+
  1678. - static const struct regmap_range axp806_volatile_ranges[] = {
  1679. - regmap_reg_range(AXP20X_IRQ1_STATE, AXP20X_IRQ2_STATE),
  1680. - };
  1681. -@@ -168,11 +220,49 @@ static const struct regmap_access_table
  1682. - .n_yes_ranges = ARRAY_SIZE(axp806_volatile_ranges),
  1683. - };
  1684. -
  1685. -+static const struct regmap_range axp15060_writeable_ranges[] = {
  1686. -+ regmap_reg_range(AXP15060_PWR_OUT_CTRL1, AXP15060_DCDC_MODE_CTRL2),
  1687. -+ regmap_reg_range(AXP15060_OUTPUT_MONITOR_DISCHARGE, AXP15060_CPUSLDO_V_CTRL),
  1688. -+ regmap_reg_range(AXP15060_PWR_WAKEUP_CTRL, AXP15060_PWR_DISABLE_DOWN_SEQ),
  1689. -+ regmap_reg_range(AXP15060_PEK_KEY, AXP15060_PEK_KEY),
  1690. -+ regmap_reg_range(AXP15060_IRQ1_EN, AXP15060_IRQ2_EN),
  1691. -+ regmap_reg_range(AXP15060_IRQ1_STATE, AXP15060_IRQ2_STATE),
  1692. -+};
  1693. -+
  1694. -+static const struct regmap_range axp15060_volatile_ranges[] = {
  1695. -+ regmap_reg_range(AXP15060_STARTUP_SRC, AXP15060_STARTUP_SRC),
  1696. -+ regmap_reg_range(AXP15060_PWR_WAKEUP_CTRL, AXP15060_PWR_DISABLE_DOWN_SEQ),
  1697. -+ regmap_reg_range(AXP15060_IRQ1_STATE, AXP15060_IRQ2_STATE),
  1698. -+};
  1699. -+
  1700. -+static const struct regmap_access_table axp15060_writeable_table = {
  1701. -+ .yes_ranges = axp15060_writeable_ranges,
  1702. -+ .n_yes_ranges = ARRAY_SIZE(axp15060_writeable_ranges),
  1703. -+};
  1704. -+
  1705. -+static const struct regmap_access_table axp15060_volatile_table = {
  1706. -+ .yes_ranges = axp15060_volatile_ranges,
  1707. -+ .n_yes_ranges = ARRAY_SIZE(axp15060_volatile_ranges),
  1708. -+};
  1709. -+
  1710. - static const struct resource axp152_pek_resources[] = {
  1711. - DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  1712. - DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1713. - };
  1714. -
  1715. -+static const struct resource axp192_ac_power_supply_resources[] = {
  1716. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
  1717. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
  1718. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
  1719. -+};
  1720. -+
  1721. -+static const struct resource axp192_usb_power_supply_resources[] = {
  1722. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
  1723. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
  1724. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_VALID, "VBUS_VALID"),
  1725. -+ DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
  1726. -+};
  1727. -+
  1728. - static const struct resource axp20x_ac_power_supply_resources[] = {
  1729. - DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
  1730. - DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
  1731. -@@ -221,6 +311,11 @@ static const struct resource axp288_fuel
  1732. - DEFINE_RES_IRQ(AXP288_IRQ_WL1),
  1733. - };
  1734. -
  1735. -+static const struct resource axp313a_pek_resources[] = {
  1736. -+ DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  1737. -+ DEFINE_RES_IRQ_NAMED(AXP313A_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1738. -+};
  1739. -+
  1740. - static const struct resource axp803_pek_resources[] = {
  1741. - DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  1742. - DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1743. -@@ -236,6 +331,11 @@ static const struct resource axp809_pek_
  1744. - DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1745. - };
  1746. -
  1747. -+static const struct resource axp15060_pek_resources[] = {
  1748. -+ DEFINE_RES_IRQ_NAMED(AXP15060_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
  1749. -+ DEFINE_RES_IRQ_NAMED(AXP15060_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
  1750. -+};
  1751. -+
  1752. - static const struct regmap_config axp152_regmap_config = {
  1753. - .reg_bits = 8,
  1754. - .val_bits = 8,
  1755. -@@ -245,6 +345,15 @@ static const struct regmap_config axp152
  1756. - .cache_type = REGCACHE_RBTREE,
  1757. - };
  1758. -
  1759. -+static const struct regmap_config axp192_regmap_config = {
  1760. -+ .reg_bits = 8,
  1761. -+ .val_bits = 8,
  1762. -+ .wr_table = &axp192_writeable_table,
  1763. -+ .volatile_table = &axp192_volatile_table,
  1764. -+ .max_register = AXP20X_CC_CTRL,
  1765. -+ .cache_type = REGCACHE_RBTREE,
  1766. -+};
  1767. -+
  1768. - static const struct regmap_config axp20x_regmap_config = {
  1769. - .reg_bits = 8,
  1770. - .val_bits = 8,
  1771. -@@ -272,6 +381,15 @@ static const struct regmap_config axp288
  1772. - .cache_type = REGCACHE_RBTREE,
  1773. - };
  1774. -
  1775. -+static const struct regmap_config axp313a_regmap_config = {
  1776. -+ .reg_bits = 8,
  1777. -+ .val_bits = 8,
  1778. -+ .wr_table = &axp313a_writeable_table,
  1779. -+ .volatile_table = &axp313a_volatile_table,
  1780. -+ .max_register = AXP313A_IRQ_STATE,
  1781. -+ .cache_type = REGCACHE_RBTREE,
  1782. -+};
  1783. -+
  1784. - static const struct regmap_config axp806_regmap_config = {
  1785. - .reg_bits = 8,
  1786. - .val_bits = 8,
  1787. -@@ -281,6 +399,15 @@ static const struct regmap_config axp806
  1788. - .cache_type = REGCACHE_RBTREE,
  1789. - };
  1790. -
  1791. -+static const struct regmap_config axp15060_regmap_config = {
  1792. -+ .reg_bits = 8,
  1793. -+ .val_bits = 8,
  1794. -+ .wr_table = &axp15060_writeable_table,
  1795. -+ .volatile_table = &axp15060_volatile_table,
  1796. -+ .max_register = AXP15060_IRQ2_STATE,
  1797. -+ .cache_type = REGCACHE_RBTREE,
  1798. -+};
  1799. -+
  1800. - #define INIT_REGMAP_IRQ(_variant, _irq, _off, _mask) \
  1801. - [_variant##_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
  1802. -
  1803. -@@ -304,6 +431,42 @@ static const struct regmap_irq axp152_re
  1804. - INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT, 2, 0),
  1805. - };
  1806. -
  1807. -+static const struct regmap_irq axp192_regmap_irqs[] = {
  1808. -+ INIT_REGMAP_IRQ(AXP192, ACIN_OVER_V, 0, 7),
  1809. -+ INIT_REGMAP_IRQ(AXP192, ACIN_PLUGIN, 0, 6),
  1810. -+ INIT_REGMAP_IRQ(AXP192, ACIN_REMOVAL, 0, 5),
  1811. -+ INIT_REGMAP_IRQ(AXP192, VBUS_OVER_V, 0, 4),
  1812. -+ INIT_REGMAP_IRQ(AXP192, VBUS_PLUGIN, 0, 3),
  1813. -+ INIT_REGMAP_IRQ(AXP192, VBUS_REMOVAL, 0, 2),
  1814. -+ INIT_REGMAP_IRQ(AXP192, VBUS_V_LOW, 0, 1),
  1815. -+ INIT_REGMAP_IRQ(AXP192, BATT_PLUGIN, 1, 7),
  1816. -+ INIT_REGMAP_IRQ(AXP192, BATT_REMOVAL, 1, 6),
  1817. -+ INIT_REGMAP_IRQ(AXP192, BATT_ENT_ACT_MODE, 1, 5),
  1818. -+ INIT_REGMAP_IRQ(AXP192, BATT_EXIT_ACT_MODE, 1, 4),
  1819. -+ INIT_REGMAP_IRQ(AXP192, CHARG, 1, 3),
  1820. -+ INIT_REGMAP_IRQ(AXP192, CHARG_DONE, 1, 2),
  1821. -+ INIT_REGMAP_IRQ(AXP192, BATT_TEMP_HIGH, 1, 1),
  1822. -+ INIT_REGMAP_IRQ(AXP192, BATT_TEMP_LOW, 1, 0),
  1823. -+ INIT_REGMAP_IRQ(AXP192, DIE_TEMP_HIGH, 2, 7),
  1824. -+ INIT_REGMAP_IRQ(AXP192, CHARG_I_LOW, 2, 6),
  1825. -+ INIT_REGMAP_IRQ(AXP192, DCDC1_V_LONG, 2, 5),
  1826. -+ INIT_REGMAP_IRQ(AXP192, DCDC2_V_LONG, 2, 4),
  1827. -+ INIT_REGMAP_IRQ(AXP192, DCDC3_V_LONG, 2, 3),
  1828. -+ INIT_REGMAP_IRQ(AXP192, PEK_SHORT, 2, 1),
  1829. -+ INIT_REGMAP_IRQ(AXP192, PEK_LONG, 2, 0),
  1830. -+ INIT_REGMAP_IRQ(AXP192, N_OE_PWR_ON, 3, 7),
  1831. -+ INIT_REGMAP_IRQ(AXP192, N_OE_PWR_OFF, 3, 6),
  1832. -+ INIT_REGMAP_IRQ(AXP192, VBUS_VALID, 3, 5),
  1833. -+ INIT_REGMAP_IRQ(AXP192, VBUS_NOT_VALID, 3, 4),
  1834. -+ INIT_REGMAP_IRQ(AXP192, VBUS_SESS_VALID, 3, 3),
  1835. -+ INIT_REGMAP_IRQ(AXP192, VBUS_SESS_END, 3, 2),
  1836. -+ INIT_REGMAP_IRQ(AXP192, LOW_PWR_LVL, 3, 0),
  1837. -+ INIT_REGMAP_IRQ(AXP192, TIMER, 4, 7),
  1838. -+ INIT_REGMAP_IRQ(AXP192, GPIO2_INPUT, 4, 2),
  1839. -+ INIT_REGMAP_IRQ(AXP192, GPIO1_INPUT, 4, 1),
  1840. -+ INIT_REGMAP_IRQ(AXP192, GPIO0_INPUT, 4, 0),
  1841. -+};
  1842. -+
  1843. - static const struct regmap_irq axp20x_regmap_irqs[] = {
  1844. - INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7),
  1845. - INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6),
  1846. -@@ -415,6 +578,16 @@ static const struct regmap_irq axp288_re
  1847. - INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1),
  1848. - };
  1849. -
  1850. -+static const struct regmap_irq axp313a_regmap_irqs[] = {
  1851. -+ INIT_REGMAP_IRQ(AXP313A, PEK_RIS_EDGE, 0, 7),
  1852. -+ INIT_REGMAP_IRQ(AXP313A, PEK_FAL_EDGE, 0, 6),
  1853. -+ INIT_REGMAP_IRQ(AXP313A, PEK_SHORT, 0, 5),
  1854. -+ INIT_REGMAP_IRQ(AXP313A, PEK_LONG, 0, 4),
  1855. -+ INIT_REGMAP_IRQ(AXP313A, DCDC3_V_LOW, 0, 3),
  1856. -+ INIT_REGMAP_IRQ(AXP313A, DCDC2_V_LOW, 0, 2),
  1857. -+ INIT_REGMAP_IRQ(AXP313A, DIE_TEMP_HIGH, 0, 0),
  1858. -+};
  1859. -+
  1860. - static const struct regmap_irq axp803_regmap_irqs[] = {
  1861. - INIT_REGMAP_IRQ(AXP803, ACIN_OVER_V, 0, 7),
  1862. - INIT_REGMAP_IRQ(AXP803, ACIN_PLUGIN, 0, 6),
  1863. -@@ -502,24 +675,65 @@ static const struct regmap_irq axp809_re
  1864. - INIT_REGMAP_IRQ(AXP809, GPIO0_INPUT, 4, 0),
  1865. - };
  1866. -
  1867. -+static const struct regmap_irq axp15060_regmap_irqs[] = {
  1868. -+ INIT_REGMAP_IRQ(AXP15060, DIE_TEMP_HIGH_LV1, 0, 0),
  1869. -+ INIT_REGMAP_IRQ(AXP15060, DIE_TEMP_HIGH_LV2, 0, 1),
  1870. -+ INIT_REGMAP_IRQ(AXP15060, DCDC1_V_LOW, 0, 2),
  1871. -+ INIT_REGMAP_IRQ(AXP15060, DCDC2_V_LOW, 0, 3),
  1872. -+ INIT_REGMAP_IRQ(AXP15060, DCDC3_V_LOW, 0, 4),
  1873. -+ INIT_REGMAP_IRQ(AXP15060, DCDC4_V_LOW, 0, 5),
  1874. -+ INIT_REGMAP_IRQ(AXP15060, DCDC5_V_LOW, 0, 6),
  1875. -+ INIT_REGMAP_IRQ(AXP15060, DCDC6_V_LOW, 0, 7),
  1876. -+ INIT_REGMAP_IRQ(AXP15060, PEK_LONG, 1, 0),
  1877. -+ INIT_REGMAP_IRQ(AXP15060, PEK_SHORT, 1, 1),
  1878. -+ INIT_REGMAP_IRQ(AXP15060, GPIO1_INPUT, 1, 2),
  1879. -+ INIT_REGMAP_IRQ(AXP15060, PEK_FAL_EDGE, 1, 3),
  1880. -+ INIT_REGMAP_IRQ(AXP15060, PEK_RIS_EDGE, 1, 4),
  1881. -+ INIT_REGMAP_IRQ(AXP15060, GPIO2_INPUT, 1, 5),
  1882. -+};
  1883. -+
  1884. - static const struct regmap_irq_chip axp152_regmap_irq_chip = {
  1885. - .name = "axp152_irq_chip",
  1886. - .status_base = AXP152_IRQ1_STATE,
  1887. - .ack_base = AXP152_IRQ1_STATE,
  1888. -- .mask_base = AXP152_IRQ1_EN,
  1889. -- .mask_invert = true,
  1890. -+ .unmask_base = AXP152_IRQ1_EN,
  1891. - .init_ack_masked = true,
  1892. - .irqs = axp152_regmap_irqs,
  1893. - .num_irqs = ARRAY_SIZE(axp152_regmap_irqs),
  1894. - .num_regs = 3,
  1895. - };
  1896. -
  1897. -+static unsigned int axp192_get_irq_reg(struct regmap_irq_chip_data *data,
  1898. -+ unsigned int base, int index)
  1899. -+{
  1900. -+ /* linear mapping for IRQ1 to IRQ4 */
  1901. -+ if (index < 4)
  1902. -+ return base + index;
  1903. -+
  1904. -+ /* handle IRQ5 separately */
  1905. -+ if (base == AXP192_IRQ1_EN)
  1906. -+ return AXP192_IRQ5_EN;
  1907. -+
  1908. -+ return AXP192_IRQ5_STATE;
  1909. -+}
  1910. -+
  1911. -+static const struct regmap_irq_chip axp192_regmap_irq_chip = {
  1912. -+ .name = "axp192_irq_chip",
  1913. -+ .status_base = AXP192_IRQ1_STATE,
  1914. -+ .ack_base = AXP192_IRQ1_STATE,
  1915. -+ .unmask_base = AXP192_IRQ1_EN,
  1916. -+ .init_ack_masked = true,
  1917. -+ .irqs = axp192_regmap_irqs,
  1918. -+ .num_irqs = ARRAY_SIZE(axp192_regmap_irqs),
  1919. -+ .num_regs = 5,
  1920. -+ .get_irq_reg = axp192_get_irq_reg,
  1921. -+};
  1922. -+
  1923. - static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
  1924. - .name = "axp20x_irq_chip",
  1925. - .status_base = AXP20X_IRQ1_STATE,
  1926. - .ack_base = AXP20X_IRQ1_STATE,
  1927. -- .mask_base = AXP20X_IRQ1_EN,
  1928. -- .mask_invert = true,
  1929. -+ .unmask_base = AXP20X_IRQ1_EN,
  1930. - .init_ack_masked = true,
  1931. - .irqs = axp20x_regmap_irqs,
  1932. - .num_irqs = ARRAY_SIZE(axp20x_regmap_irqs),
  1933. -@@ -531,8 +745,7 @@ static const struct regmap_irq_chip axp2
  1934. - .name = "axp22x_irq_chip",
  1935. - .status_base = AXP20X_IRQ1_STATE,
  1936. - .ack_base = AXP20X_IRQ1_STATE,
  1937. -- .mask_base = AXP20X_IRQ1_EN,
  1938. -- .mask_invert = true,
  1939. -+ .unmask_base = AXP20X_IRQ1_EN,
  1940. - .init_ack_masked = true,
  1941. - .irqs = axp22x_regmap_irqs,
  1942. - .num_irqs = ARRAY_SIZE(axp22x_regmap_irqs),
  1943. -@@ -543,8 +756,7 @@ static const struct regmap_irq_chip axp2
  1944. - .name = "axp288_irq_chip",
  1945. - .status_base = AXP20X_IRQ1_STATE,
  1946. - .ack_base = AXP20X_IRQ1_STATE,
  1947. -- .mask_base = AXP20X_IRQ1_EN,
  1948. -- .mask_invert = true,
  1949. -+ .unmask_base = AXP20X_IRQ1_EN,
  1950. - .init_ack_masked = true,
  1951. - .irqs = axp288_regmap_irqs,
  1952. - .num_irqs = ARRAY_SIZE(axp288_regmap_irqs),
  1953. -@@ -552,12 +764,22 @@ static const struct regmap_irq_chip axp2
  1954. -
  1955. - };
  1956. -
  1957. -+static const struct regmap_irq_chip axp313a_regmap_irq_chip = {
  1958. -+ .name = "axp313a_irq_chip",
  1959. -+ .status_base = AXP313A_IRQ_STATE,
  1960. -+ .ack_base = AXP313A_IRQ_STATE,
  1961. -+ .unmask_base = AXP313A_IRQ_EN,
  1962. -+ .init_ack_masked = true,
  1963. -+ .irqs = axp313a_regmap_irqs,
  1964. -+ .num_irqs = ARRAY_SIZE(axp313a_regmap_irqs),
  1965. -+ .num_regs = 1,
  1966. -+};
  1967. -+
  1968. - static const struct regmap_irq_chip axp803_regmap_irq_chip = {
  1969. - .name = "axp803",
  1970. - .status_base = AXP20X_IRQ1_STATE,
  1971. - .ack_base = AXP20X_IRQ1_STATE,
  1972. -- .mask_base = AXP20X_IRQ1_EN,
  1973. -- .mask_invert = true,
  1974. -+ .unmask_base = AXP20X_IRQ1_EN,
  1975. - .init_ack_masked = true,
  1976. - .irqs = axp803_regmap_irqs,
  1977. - .num_irqs = ARRAY_SIZE(axp803_regmap_irqs),
  1978. -@@ -568,8 +790,7 @@ static const struct regmap_irq_chip axp8
  1979. - .name = "axp806",
  1980. - .status_base = AXP20X_IRQ1_STATE,
  1981. - .ack_base = AXP20X_IRQ1_STATE,
  1982. -- .mask_base = AXP20X_IRQ1_EN,
  1983. -- .mask_invert = true,
  1984. -+ .unmask_base = AXP20X_IRQ1_EN,
  1985. - .init_ack_masked = true,
  1986. - .irqs = axp806_regmap_irqs,
  1987. - .num_irqs = ARRAY_SIZE(axp806_regmap_irqs),
  1988. -@@ -580,14 +801,45 @@ static const struct regmap_irq_chip axp8
  1989. - .name = "axp809",
  1990. - .status_base = AXP20X_IRQ1_STATE,
  1991. - .ack_base = AXP20X_IRQ1_STATE,
  1992. -- .mask_base = AXP20X_IRQ1_EN,
  1993. -- .mask_invert = true,
  1994. -+ .unmask_base = AXP20X_IRQ1_EN,
  1995. - .init_ack_masked = true,
  1996. - .irqs = axp809_regmap_irqs,
  1997. - .num_irqs = ARRAY_SIZE(axp809_regmap_irqs),
  1998. - .num_regs = 5,
  1999. - };
  2000. -
  2001. -+static const struct regmap_irq_chip axp15060_regmap_irq_chip = {
  2002. -+ .name = "axp15060",
  2003. -+ .status_base = AXP15060_IRQ1_STATE,
  2004. -+ .ack_base = AXP15060_IRQ1_STATE,
  2005. -+ .unmask_base = AXP15060_IRQ1_EN,
  2006. -+ .init_ack_masked = true,
  2007. -+ .irqs = axp15060_regmap_irqs,
  2008. -+ .num_irqs = ARRAY_SIZE(axp15060_regmap_irqs),
  2009. -+ .num_regs = 2,
  2010. -+};
  2011. -+
  2012. -+static const struct mfd_cell axp192_cells[] = {
  2013. -+ {
  2014. -+ .name = "axp192-adc",
  2015. -+ .of_compatible = "x-powers,axp192-adc",
  2016. -+ }, {
  2017. -+ .name = "axp20x-battery-power-supply",
  2018. -+ .of_compatible = "x-powers,axp192-battery-power-supply",
  2019. -+ }, {
  2020. -+ .name = "axp20x-ac-power-supply",
  2021. -+ .of_compatible = "x-powers,axp202-ac-power-supply",
  2022. -+ .num_resources = ARRAY_SIZE(axp192_ac_power_supply_resources),
  2023. -+ .resources = axp192_ac_power_supply_resources,
  2024. -+ }, {
  2025. -+ .name = "axp20x-usb-power-supply",
  2026. -+ .of_compatible = "x-powers,axp192-usb-power-supply",
  2027. -+ .num_resources = ARRAY_SIZE(axp192_usb_power_supply_resources),
  2028. -+ .resources = axp192_usb_power_supply_resources,
  2029. -+ },
  2030. -+ { .name = "axp20x-regulator" },
  2031. -+};
  2032. -+
  2033. - static const struct mfd_cell axp20x_cells[] = {
  2034. - {
  2035. - .name = "axp20x-gpio",
  2036. -@@ -683,6 +935,11 @@ static const struct mfd_cell axp152_cell
  2037. - },
  2038. - };
  2039. -
  2040. -+static struct mfd_cell axp313a_cells[] = {
  2041. -+ MFD_CELL_NAME("axp20x-regulator"),
  2042. -+ MFD_CELL_RES("axp313a-pek", axp313a_pek_resources),
  2043. -+};
  2044. -+
  2045. - static const struct resource axp288_adc_resources[] = {
  2046. - DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"),
  2047. - };
  2048. -@@ -832,17 +1089,43 @@ static const struct mfd_cell axp813_cell
  2049. - },
  2050. - };
  2051. -
  2052. --static struct axp20x_dev *axp20x_pm_power_off;
  2053. --static void axp20x_power_off(void)
  2054. -+static const struct mfd_cell axp15060_cells[] = {
  2055. -+ {
  2056. -+ .name = "axp221-pek",
  2057. -+ .num_resources = ARRAY_SIZE(axp15060_pek_resources),
  2058. -+ .resources = axp15060_pek_resources,
  2059. -+ }, {
  2060. -+ .name = "axp20x-regulator",
  2061. -+ },
  2062. -+};
  2063. -+
  2064. -+/* For boards that don't have IRQ line connected to SOC. */
  2065. -+static const struct mfd_cell axp_regulator_only_cells[] = {
  2066. -+ {
  2067. -+ .name = "axp20x-regulator",
  2068. -+ },
  2069. -+};
  2070. -+
  2071. -+static int axp20x_power_off(struct sys_off_data *data)
  2072. - {
  2073. -- if (axp20x_pm_power_off->variant == AXP288_ID)
  2074. -- return;
  2075. -+ struct axp20x_dev *axp20x = data->cb_data;
  2076. -+ unsigned int shutdown_reg;
  2077. -
  2078. -- regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
  2079. -- AXP20X_OFF);
  2080. -+ switch (axp20x->variant) {
  2081. -+ case AXP313A_ID:
  2082. -+ shutdown_reg = AXP313A_SHUTDOWN_CTRL;
  2083. -+ break;
  2084. -+ default:
  2085. -+ shutdown_reg = AXP20X_OFF_CTRL;
  2086. -+ break;
  2087. -+ }
  2088. -+
  2089. -+ regmap_write(axp20x->regmap, shutdown_reg, AXP20X_OFF);
  2090. -
  2091. - /* Give capacitors etc. time to drain to avoid kernel panic msg. */
  2092. - mdelay(500);
  2093. -+
  2094. -+ return NOTIFY_DONE;
  2095. - }
  2096. -
  2097. - int axp20x_match_device(struct axp20x_dev *axp20x)
  2098. -@@ -874,6 +1157,12 @@ int axp20x_match_device(struct axp20x_de
  2099. - axp20x->regmap_cfg = &axp152_regmap_config;
  2100. - axp20x->regmap_irq_chip = &axp152_regmap_irq_chip;
  2101. - break;
  2102. -+ case AXP192_ID:
  2103. -+ axp20x->nr_cells = ARRAY_SIZE(axp192_cells);
  2104. -+ axp20x->cells = axp192_cells;
  2105. -+ axp20x->regmap_cfg = &axp192_regmap_config;
  2106. -+ axp20x->regmap_irq_chip = &axp192_regmap_irq_chip;
  2107. -+ break;
  2108. - case AXP202_ID:
  2109. - case AXP209_ID:
  2110. - axp20x->nr_cells = ARRAY_SIZE(axp20x_cells);
  2111. -@@ -900,6 +1189,12 @@ int axp20x_match_device(struct axp20x_de
  2112. - axp20x->regmap_irq_chip = &axp288_regmap_irq_chip;
  2113. - axp20x->irq_flags = IRQF_TRIGGER_LOW;
  2114. - break;
  2115. -+ case AXP313A_ID:
  2116. -+ axp20x->nr_cells = ARRAY_SIZE(axp313a_cells);
  2117. -+ axp20x->cells = axp313a_cells;
  2118. -+ axp20x->regmap_cfg = &axp313a_regmap_config;
  2119. -+ axp20x->regmap_irq_chip = &axp313a_regmap_irq_chip;
  2120. -+ break;
  2121. - case AXP803_ID:
  2122. - axp20x->nr_cells = ARRAY_SIZE(axp803_cells);
  2123. - axp20x->cells = axp803_cells;
  2124. -@@ -942,6 +1237,28 @@ int axp20x_match_device(struct axp20x_de
  2125. - */
  2126. - axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
  2127. - break;
  2128. -+ case AXP15060_ID:
  2129. -+ /*
  2130. -+ * Don't register the power key part if there is no interrupt
  2131. -+ * line.
  2132. -+ *
  2133. -+ * Since most use cases of AXP PMICs are Allwinner SOCs, board
  2134. -+ * designers follow Allwinner's reference design and connects
  2135. -+ * IRQ line to SOC, there's no need for those variants to deal
  2136. -+ * with cases that IRQ isn't connected. However, AXP15660 is
  2137. -+ * used by some other vendors' SOCs that didn't connect IRQ
  2138. -+ * line, we need to deal with this case.
  2139. -+ */
  2140. -+ if (axp20x->irq > 0) {
  2141. -+ axp20x->nr_cells = ARRAY_SIZE(axp15060_cells);
  2142. -+ axp20x->cells = axp15060_cells;
  2143. -+ } else {
  2144. -+ axp20x->nr_cells = ARRAY_SIZE(axp_regulator_only_cells);
  2145. -+ axp20x->cells = axp_regulator_only_cells;
  2146. -+ }
  2147. -+ axp20x->regmap_cfg = &axp15060_regmap_config;
  2148. -+ axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip;
  2149. -+ break;
  2150. - default:
  2151. - dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
  2152. - return -EINVAL;
  2153. -@@ -1009,10 +1326,11 @@ int axp20x_device_probe(struct axp20x_de
  2154. - return ret;
  2155. - }
  2156. -
  2157. -- if (!pm_power_off) {
  2158. -- axp20x_pm_power_off = axp20x;
  2159. -- pm_power_off = axp20x_power_off;
  2160. -- }
  2161. -+ if (axp20x->variant != AXP288_ID)
  2162. -+ devm_register_sys_off_handler(axp20x->dev,
  2163. -+ SYS_OFF_MODE_POWER_OFF,
  2164. -+ SYS_OFF_PRIO_DEFAULT,
  2165. -+ axp20x_power_off, axp20x);
  2166. -
  2167. - dev_info(axp20x->dev, "AXP20X driver loaded\n");
  2168. -
  2169. -@@ -1022,11 +1340,6 @@ EXPORT_SYMBOL(axp20x_device_probe);
  2170. -
  2171. - void axp20x_device_remove(struct axp20x_dev *axp20x)
  2172. - {
  2173. -- if (axp20x == axp20x_pm_power_off) {
  2174. -- axp20x_pm_power_off = NULL;
  2175. -- pm_power_off = NULL;
  2176. -- }
  2177. --
  2178. - mfd_remove_devices(axp20x->dev);
  2179. - regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
  2180. - }
  2181. ---- a/include/linux/mfd/axp20x.h
  2182. -+++ b/include/linux/mfd/axp20x.h
  2183. -@@ -12,18 +12,22 @@
  2184. -
  2185. - enum axp20x_variants {
  2186. - AXP152_ID = 0,
  2187. -+ AXP192_ID,
  2188. - AXP202_ID,
  2189. - AXP209_ID,
  2190. - AXP221_ID,
  2191. - AXP223_ID,
  2192. - AXP288_ID,
  2193. -+ AXP313A_ID,
  2194. - AXP803_ID,
  2195. - AXP806_ID,
  2196. - AXP809_ID,
  2197. - AXP813_ID,
  2198. -+ AXP15060_ID,
  2199. - NR_AXP20X_VARIANTS,
  2200. - };
  2201. -
  2202. -+#define AXP192_DATACACHE(m) (0x06 + (m))
  2203. - #define AXP20X_DATACACHE(m) (0x04 + (m))
  2204. -
  2205. - /* Power supply */
  2206. -@@ -45,6 +49,13 @@ enum axp20x_variants {
  2207. - #define AXP152_DCDC_FREQ 0x37
  2208. - #define AXP152_DCDC_MODE 0x80
  2209. -
  2210. -+#define AXP192_USB_OTG_STATUS 0x04
  2211. -+#define AXP192_PWR_OUT_CTRL 0x12
  2212. -+#define AXP192_DCDC2_V_OUT 0x23
  2213. -+#define AXP192_DCDC1_V_OUT 0x26
  2214. -+#define AXP192_DCDC3_V_OUT 0x27
  2215. -+#define AXP192_LDO2_3_V_OUT 0x28
  2216. -+
  2217. - #define AXP20X_PWR_INPUT_STATUS 0x00
  2218. - #define AXP20X_PWR_OP_MODE 0x01
  2219. - #define AXP20X_USB_OTG_STATUS 0x02
  2220. -@@ -91,6 +102,17 @@ enum axp20x_variants {
  2221. - #define AXP22X_ALDO3_V_OUT 0x2a
  2222. - #define AXP22X_CHRG_CTRL3 0x35
  2223. -
  2224. -+#define AXP313A_ON_INDICATE 0x00
  2225. -+#define AXP313A_OUTPUT_CONTROL 0x10
  2226. -+#define AXP313A_DCDC1_CONRTOL 0x13
  2227. -+#define AXP313A_DCDC2_CONRTOL 0x14
  2228. -+#define AXP313A_DCDC3_CONRTOL 0x15
  2229. -+#define AXP313A_ALDO1_CONRTOL 0x16
  2230. -+#define AXP313A_DLDO1_CONRTOL 0x17
  2231. -+#define AXP313A_SHUTDOWN_CTRL 0x1a
  2232. -+#define AXP313A_IRQ_EN 0x20
  2233. -+#define AXP313A_IRQ_STATE 0x21
  2234. -+
  2235. - #define AXP806_STARTUP_SRC 0x00
  2236. - #define AXP806_CHIP_ID 0x03
  2237. - #define AXP806_PWR_OUT_CTRL1 0x10
  2238. -@@ -131,6 +153,39 @@ enum axp20x_variants {
  2239. - /* Other DCDC regulator control registers are the same as AXP803 */
  2240. - #define AXP813_DCDC7_V_OUT 0x26
  2241. -
  2242. -+#define AXP15060_STARTUP_SRC 0x00
  2243. -+#define AXP15060_PWR_OUT_CTRL1 0x10
  2244. -+#define AXP15060_PWR_OUT_CTRL2 0x11
  2245. -+#define AXP15060_PWR_OUT_CTRL3 0x12
  2246. -+#define AXP15060_DCDC1_V_CTRL 0x13
  2247. -+#define AXP15060_DCDC2_V_CTRL 0x14
  2248. -+#define AXP15060_DCDC3_V_CTRL 0x15
  2249. -+#define AXP15060_DCDC4_V_CTRL 0x16
  2250. -+#define AXP15060_DCDC5_V_CTRL 0x17
  2251. -+#define AXP15060_DCDC6_V_CTRL 0x18
  2252. -+#define AXP15060_ALDO1_V_CTRL 0x19
  2253. -+#define AXP15060_DCDC_MODE_CTRL1 0x1a
  2254. -+#define AXP15060_DCDC_MODE_CTRL2 0x1b
  2255. -+#define AXP15060_OUTPUT_MONITOR_DISCHARGE 0x1e
  2256. -+#define AXP15060_IRQ_PWROK_VOFF 0x1f
  2257. -+#define AXP15060_ALDO2_V_CTRL 0x20
  2258. -+#define AXP15060_ALDO3_V_CTRL 0x21
  2259. -+#define AXP15060_ALDO4_V_CTRL 0x22
  2260. -+#define AXP15060_ALDO5_V_CTRL 0x23
  2261. -+#define AXP15060_BLDO1_V_CTRL 0x24
  2262. -+#define AXP15060_BLDO2_V_CTRL 0x25
  2263. -+#define AXP15060_BLDO3_V_CTRL 0x26
  2264. -+#define AXP15060_BLDO4_V_CTRL 0x27
  2265. -+#define AXP15060_BLDO5_V_CTRL 0x28
  2266. -+#define AXP15060_CLDO1_V_CTRL 0x29
  2267. -+#define AXP15060_CLDO2_V_CTRL 0x2a
  2268. -+#define AXP15060_CLDO3_V_CTRL 0x2b
  2269. -+#define AXP15060_CLDO4_V_CTRL 0x2d
  2270. -+#define AXP15060_CPUSLDO_V_CTRL 0x2e
  2271. -+#define AXP15060_PWR_WAKEUP_CTRL 0x31
  2272. -+#define AXP15060_PWR_DISABLE_DOWN_SEQ 0x32
  2273. -+#define AXP15060_PEK_KEY 0x36
  2274. -+
  2275. - /* Interrupt */
  2276. - #define AXP152_IRQ1_EN 0x40
  2277. - #define AXP152_IRQ2_EN 0x41
  2278. -@@ -139,6 +194,17 @@ enum axp20x_variants {
  2279. - #define AXP152_IRQ2_STATE 0x49
  2280. - #define AXP152_IRQ3_STATE 0x4a
  2281. -
  2282. -+#define AXP192_IRQ1_EN 0x40
  2283. -+#define AXP192_IRQ2_EN 0x41
  2284. -+#define AXP192_IRQ3_EN 0x42
  2285. -+#define AXP192_IRQ4_EN 0x43
  2286. -+#define AXP192_IRQ1_STATE 0x44
  2287. -+#define AXP192_IRQ2_STATE 0x45
  2288. -+#define AXP192_IRQ3_STATE 0x46
  2289. -+#define AXP192_IRQ4_STATE 0x47
  2290. -+#define AXP192_IRQ5_EN 0x4a
  2291. -+#define AXP192_IRQ5_STATE 0x4d
  2292. -+
  2293. - #define AXP20X_IRQ1_EN 0x40
  2294. - #define AXP20X_IRQ2_EN 0x41
  2295. - #define AXP20X_IRQ3_EN 0x42
  2296. -@@ -152,7 +218,17 @@ enum axp20x_variants {
  2297. - #define AXP20X_IRQ5_STATE 0x4c
  2298. - #define AXP20X_IRQ6_STATE 0x4d
  2299. -
  2300. -+#define AXP15060_IRQ1_EN 0x40
  2301. -+#define AXP15060_IRQ2_EN 0x41
  2302. -+#define AXP15060_IRQ1_STATE 0x48
  2303. -+#define AXP15060_IRQ2_STATE 0x49
  2304. -+
  2305. - /* ADC */
  2306. -+#define AXP192_GPIO2_V_ADC_H 0x68
  2307. -+#define AXP192_GPIO2_V_ADC_L 0x69
  2308. -+#define AXP192_GPIO3_V_ADC_H 0x6a
  2309. -+#define AXP192_GPIO3_V_ADC_L 0x6b
  2310. -+
  2311. - #define AXP20X_ACIN_V_ADC_H 0x56
  2312. - #define AXP20X_ACIN_V_ADC_L 0x57
  2313. - #define AXP20X_ACIN_I_ADC_H 0x58
  2314. -@@ -182,6 +258,8 @@ enum axp20x_variants {
  2315. - #define AXP20X_IPSOUT_V_HIGH_L 0x7f
  2316. -
  2317. - /* Power supply */
  2318. -+#define AXP192_GPIO30_IN_RANGE 0x85
  2319. -+
  2320. - #define AXP20X_DCDC_MODE 0x80
  2321. - #define AXP20X_ADC_EN1 0x82
  2322. - #define AXP20X_ADC_EN2 0x83
  2323. -@@ -210,6 +288,16 @@ enum axp20x_variants {
  2324. - #define AXP152_PWM1_FREQ_Y 0x9c
  2325. - #define AXP152_PWM1_DUTY_CYCLE 0x9d
  2326. -
  2327. -+#define AXP192_GPIO0_CTRL 0x90
  2328. -+#define AXP192_LDO_IO0_V_OUT 0x91
  2329. -+#define AXP192_GPIO1_CTRL 0x92
  2330. -+#define AXP192_GPIO2_CTRL 0x93
  2331. -+#define AXP192_GPIO2_0_STATE 0x94
  2332. -+#define AXP192_GPIO4_3_CTRL 0x95
  2333. -+#define AXP192_GPIO4_3_STATE 0x96
  2334. -+#define AXP192_GPIO2_0_PULL 0x97
  2335. -+#define AXP192_N_RSTO_CTRL 0x9e
  2336. -+
  2337. - #define AXP20X_GPIO0_CTRL 0x90
  2338. - #define AXP20X_LDO5_V_OUT 0x91
  2339. - #define AXP20X_GPIO1_CTRL 0x92
  2340. -@@ -222,6 +310,8 @@ enum axp20x_variants {
  2341. - #define AXP22X_GPIO_STATE 0x94
  2342. - #define AXP22X_GPIO_PULL_DOWN 0x95
  2343. -
  2344. -+#define AXP15060_CLDO4_GPIO2_MODESET 0x2c
  2345. -+
  2346. - /* Battery */
  2347. - #define AXP20X_CHRG_CC_31_24 0xb0
  2348. - #define AXP20X_CHRG_CC_23_16 0xb1
  2349. -@@ -288,6 +378,17 @@ enum axp20x_variants {
  2350. -
  2351. - /* Regulators IDs */
  2352. - enum {
  2353. -+ AXP192_DCDC1 = 0,
  2354. -+ AXP192_DCDC2,
  2355. -+ AXP192_DCDC3,
  2356. -+ AXP192_LDO1,
  2357. -+ AXP192_LDO2,
  2358. -+ AXP192_LDO3,
  2359. -+ AXP192_LDO_IO0,
  2360. -+ AXP192_REG_ID_MAX
  2361. -+};
  2362. -+
  2363. -+enum {
  2364. - AXP20X_LDO1 = 0,
  2365. - AXP20X_LDO2,
  2366. - AXP20X_LDO3,
  2367. -@@ -323,6 +424,16 @@ enum {
  2368. - };
  2369. -
  2370. - enum {
  2371. -+ AXP313A_DCDC1 = 0,
  2372. -+ AXP313A_DCDC2,
  2373. -+ AXP313A_DCDC3,
  2374. -+ AXP313A_ALDO1,
  2375. -+ AXP313A_DLDO1,
  2376. -+ AXP313A_RTC_LDO,
  2377. -+ AXP313A_REG_ID_MAX,
  2378. -+};
  2379. -+
  2380. -+enum {
  2381. - AXP806_DCDCA = 0,
  2382. - AXP806_DCDCB,
  2383. - AXP806_DCDCC,
  2384. -@@ -419,6 +530,33 @@ enum {
  2385. - AXP813_REG_ID_MAX,
  2386. - };
  2387. -
  2388. -+enum {
  2389. -+ AXP15060_DCDC1 = 0,
  2390. -+ AXP15060_DCDC2,
  2391. -+ AXP15060_DCDC3,
  2392. -+ AXP15060_DCDC4,
  2393. -+ AXP15060_DCDC5,
  2394. -+ AXP15060_DCDC6,
  2395. -+ AXP15060_ALDO1,
  2396. -+ AXP15060_ALDO2,
  2397. -+ AXP15060_ALDO3,
  2398. -+ AXP15060_ALDO4,
  2399. -+ AXP15060_ALDO5,
  2400. -+ AXP15060_BLDO1,
  2401. -+ AXP15060_BLDO2,
  2402. -+ AXP15060_BLDO3,
  2403. -+ AXP15060_BLDO4,
  2404. -+ AXP15060_BLDO5,
  2405. -+ AXP15060_CLDO1,
  2406. -+ AXP15060_CLDO2,
  2407. -+ AXP15060_CLDO3,
  2408. -+ AXP15060_CLDO4,
  2409. -+ AXP15060_CPUSLDO,
  2410. -+ AXP15060_SW,
  2411. -+ AXP15060_RTC_LDO,
  2412. -+ AXP15060_REG_ID_MAX,
  2413. -+};
  2414. -+
  2415. - /* IRQs */
  2416. - enum {
  2417. - AXP152_IRQ_LDO0IN_CONNECT = 1,
  2418. -@@ -432,14 +570,51 @@ enum {
  2419. - AXP152_IRQ_PEK_SHORT,
  2420. - AXP152_IRQ_PEK_LONG,
  2421. - AXP152_IRQ_TIMER,
  2422. -- AXP152_IRQ_PEK_RIS_EDGE,
  2423. -+ /* out of bit order to make sure the press event is handled first */
  2424. - AXP152_IRQ_PEK_FAL_EDGE,
  2425. -+ AXP152_IRQ_PEK_RIS_EDGE,
  2426. - AXP152_IRQ_GPIO3_INPUT,
  2427. - AXP152_IRQ_GPIO2_INPUT,
  2428. - AXP152_IRQ_GPIO1_INPUT,
  2429. - AXP152_IRQ_GPIO0_INPUT,
  2430. - };
  2431. -
  2432. -+enum axp192_irqs {
  2433. -+ AXP192_IRQ_ACIN_OVER_V = 1,
  2434. -+ AXP192_IRQ_ACIN_PLUGIN,
  2435. -+ AXP192_IRQ_ACIN_REMOVAL,
  2436. -+ AXP192_IRQ_VBUS_OVER_V,
  2437. -+ AXP192_IRQ_VBUS_PLUGIN,
  2438. -+ AXP192_IRQ_VBUS_REMOVAL,
  2439. -+ AXP192_IRQ_VBUS_V_LOW,
  2440. -+ AXP192_IRQ_BATT_PLUGIN,
  2441. -+ AXP192_IRQ_BATT_REMOVAL,
  2442. -+ AXP192_IRQ_BATT_ENT_ACT_MODE,
  2443. -+ AXP192_IRQ_BATT_EXIT_ACT_MODE,
  2444. -+ AXP192_IRQ_CHARG,
  2445. -+ AXP192_IRQ_CHARG_DONE,
  2446. -+ AXP192_IRQ_BATT_TEMP_HIGH,
  2447. -+ AXP192_IRQ_BATT_TEMP_LOW,
  2448. -+ AXP192_IRQ_DIE_TEMP_HIGH,
  2449. -+ AXP192_IRQ_CHARG_I_LOW,
  2450. -+ AXP192_IRQ_DCDC1_V_LONG,
  2451. -+ AXP192_IRQ_DCDC2_V_LONG,
  2452. -+ AXP192_IRQ_DCDC3_V_LONG,
  2453. -+ AXP192_IRQ_PEK_SHORT = 22,
  2454. -+ AXP192_IRQ_PEK_LONG,
  2455. -+ AXP192_IRQ_N_OE_PWR_ON,
  2456. -+ AXP192_IRQ_N_OE_PWR_OFF,
  2457. -+ AXP192_IRQ_VBUS_VALID,
  2458. -+ AXP192_IRQ_VBUS_NOT_VALID,
  2459. -+ AXP192_IRQ_VBUS_SESS_VALID,
  2460. -+ AXP192_IRQ_VBUS_SESS_END,
  2461. -+ AXP192_IRQ_LOW_PWR_LVL = 31,
  2462. -+ AXP192_IRQ_TIMER,
  2463. -+ AXP192_IRQ_GPIO2_INPUT = 37,
  2464. -+ AXP192_IRQ_GPIO1_INPUT,
  2465. -+ AXP192_IRQ_GPIO0_INPUT,
  2466. -+};
  2467. -+
  2468. - enum {
  2469. - AXP20X_IRQ_ACIN_OVER_V = 1,
  2470. - AXP20X_IRQ_ACIN_PLUGIN,
  2471. -@@ -472,8 +647,9 @@ enum {
  2472. - AXP20X_IRQ_LOW_PWR_LVL1,
  2473. - AXP20X_IRQ_LOW_PWR_LVL2,
  2474. - AXP20X_IRQ_TIMER,
  2475. -- AXP20X_IRQ_PEK_RIS_EDGE,
  2476. -+ /* out of bit order to make sure the press event is handled first */
  2477. - AXP20X_IRQ_PEK_FAL_EDGE,
  2478. -+ AXP20X_IRQ_PEK_RIS_EDGE,
  2479. - AXP20X_IRQ_GPIO3_INPUT,
  2480. - AXP20X_IRQ_GPIO2_INPUT,
  2481. - AXP20X_IRQ_GPIO1_INPUT,
  2482. -@@ -502,8 +678,9 @@ enum axp22x_irqs {
  2483. - AXP22X_IRQ_LOW_PWR_LVL1,
  2484. - AXP22X_IRQ_LOW_PWR_LVL2,
  2485. - AXP22X_IRQ_TIMER,
  2486. -- AXP22X_IRQ_PEK_RIS_EDGE,
  2487. -+ /* out of bit order to make sure the press event is handled first */
  2488. - AXP22X_IRQ_PEK_FAL_EDGE,
  2489. -+ AXP22X_IRQ_PEK_RIS_EDGE,
  2490. - AXP22X_IRQ_GPIO1_INPUT,
  2491. - AXP22X_IRQ_GPIO0_INPUT,
  2492. - };
  2493. -@@ -545,6 +722,16 @@ enum axp288_irqs {
  2494. - AXP288_IRQ_BC_USB_CHNG,
  2495. - };
  2496. -
  2497. -+enum axp313a_irqs {
  2498. -+ AXP313A_IRQ_DIE_TEMP_HIGH,
  2499. -+ AXP313A_IRQ_DCDC2_V_LOW = 2,
  2500. -+ AXP313A_IRQ_DCDC3_V_LOW,
  2501. -+ AXP313A_IRQ_PEK_LONG,
  2502. -+ AXP313A_IRQ_PEK_SHORT,
  2503. -+ AXP313A_IRQ_PEK_FAL_EDGE,
  2504. -+ AXP313A_IRQ_PEK_RIS_EDGE,
  2505. -+};
  2506. -+
  2507. - enum axp803_irqs {
  2508. - AXP803_IRQ_ACIN_OVER_V = 1,
  2509. - AXP803_IRQ_ACIN_PLUGIN,
  2510. -@@ -571,8 +758,9 @@ enum axp803_irqs {
  2511. - AXP803_IRQ_LOW_PWR_LVL1,
  2512. - AXP803_IRQ_LOW_PWR_LVL2,
  2513. - AXP803_IRQ_TIMER,
  2514. -- AXP803_IRQ_PEK_RIS_EDGE,
  2515. -+ /* out of bit order to make sure the press event is handled first */
  2516. - AXP803_IRQ_PEK_FAL_EDGE,
  2517. -+ AXP803_IRQ_PEK_RIS_EDGE,
  2518. - AXP803_IRQ_PEK_SHORT,
  2519. - AXP803_IRQ_PEK_LONG,
  2520. - AXP803_IRQ_PEK_OVER_OFF,
  2521. -@@ -623,8 +811,9 @@ enum axp809_irqs {
  2522. - AXP809_IRQ_LOW_PWR_LVL1,
  2523. - AXP809_IRQ_LOW_PWR_LVL2,
  2524. - AXP809_IRQ_TIMER,
  2525. -- AXP809_IRQ_PEK_RIS_EDGE,
  2526. -+ /* out of bit order to make sure the press event is handled first */
  2527. - AXP809_IRQ_PEK_FAL_EDGE,
  2528. -+ AXP809_IRQ_PEK_RIS_EDGE,
  2529. - AXP809_IRQ_PEK_SHORT,
  2530. - AXP809_IRQ_PEK_LONG,
  2531. - AXP809_IRQ_PEK_OVER_OFF,
  2532. -@@ -632,6 +821,23 @@ enum axp809_irqs {
  2533. - AXP809_IRQ_GPIO0_INPUT,
  2534. - };
  2535. -
  2536. -+enum axp15060_irqs {
  2537. -+ AXP15060_IRQ_DIE_TEMP_HIGH_LV1 = 1,
  2538. -+ AXP15060_IRQ_DIE_TEMP_HIGH_LV2,
  2539. -+ AXP15060_IRQ_DCDC1_V_LOW,
  2540. -+ AXP15060_IRQ_DCDC2_V_LOW,
  2541. -+ AXP15060_IRQ_DCDC3_V_LOW,
  2542. -+ AXP15060_IRQ_DCDC4_V_LOW,
  2543. -+ AXP15060_IRQ_DCDC5_V_LOW,
  2544. -+ AXP15060_IRQ_DCDC6_V_LOW,
  2545. -+ AXP15060_IRQ_PEK_LONG,
  2546. -+ AXP15060_IRQ_PEK_SHORT,
  2547. -+ AXP15060_IRQ_GPIO1_INPUT,
  2548. -+ AXP15060_IRQ_PEK_FAL_EDGE,
  2549. -+ AXP15060_IRQ_PEK_RIS_EDGE,
  2550. -+ AXP15060_IRQ_GPIO2_INPUT,
  2551. -+};
  2552. -+
  2553. - struct axp20x_dev {
  2554. - struct device *dev;
  2555. - int irq;
  2556. -@@ -698,4 +904,4 @@ int axp20x_device_probe(struct axp20x_de
  2557. - */
  2558. - void axp20x_device_remove(struct axp20x_dev *axp20x);
  2559. -
  2560. --#endif /* __LINUX_MFD_AXP20X_H */
  2561. -+#endif /* __LINUX_MFD_AXP20X_H */
  2562. -\ No newline at end of file
  2563. From 78ee0a6febcd62e931fe70ce62bd2fe68038dc78 Mon Sep 17 00:00:00 2001
  2564. From: Chukun Pan <[email protected]>
  2565. Date: Sat, 18 Nov 2023 23:10:25 +0800
  2566. Subject: [PATCH 3/4] sunxi: add support for Orange Pi Zero 3
  2567. Key features:
  2568. Allwinner H618 SoC (Quad core Cortex-A53)
  2569. 1/1.5/2/4 GiB LPDDR4 DRAM
  2570. 1 USB 2.0 type C port (Power + OTG)
  2571. 1 USB 2.0 host port
  2572. 1Gbps Ethernet port
  2573. Micro-HDMI port
  2574. MicroSD slot
  2575. Installation:
  2576. Write the image to SD Card with dd.
  2577. Signed-off-by: Chukun Pan <[email protected]>
  2578. ---
  2579. package/boot/uboot-sunxi/Makefile | 10 +
  2580. target/linux/sunxi/cortexa53/config-6.1 | 1 +
  2581. target/linux/sunxi/image/cortexa53.mk | 12 +
  2582. ...inner-h616-Split-Orange-Pi-Zero-2-DT.patch | 305 ++++++++++++++++++
  2583. ...inner-h616-Add-OrangePi-Zero-3-board.patch | 140 ++++++++
  2584. ...inner-h616-update-emac-for-Orange-Pi.patch | 57 ++++
  2585. 6 files changed, 525 insertions(+)
  2586. create mode 100644 target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch
  2587. create mode 100644 target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch
  2588. create mode 100644 target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch
  2589. diff --git a/package/boot/uboot-sunxi/Makefile b/package/boot/uboot-sunxi/Makefile
  2590. index de07dbdec2e97..112ea47d21d76 100644
  2591. --- a/package/boot/uboot-sunxi/Makefile
  2592. +++ b/package/boot/uboot-sunxi/Makefile
  2593. @@ -339,6 +339,15 @@ define U-Boot/orangepi_zero2
  2594. ATF:=h616
  2595. endef
  2596. +define U-Boot/orangepi_zero3
  2597. + BUILD_SUBTARGET:=cortexa53
  2598. + NAME:=Xunlong Orange Pi Zero3
  2599. + BUILD_DEVICES:=xunlong_orangepi-zero3
  2600. + DEPENDS:=+PACKAGE_u-boot-orangepi_zero3:trusted-firmware-a-sunxi-h616
  2601. + UENV:=h616
  2602. + ATF:=h616
  2603. +endef
  2604. +
  2605. define U-Boot/Bananapi_M2_Ultra
  2606. BUILD_SUBTARGET:=cortexa7
  2607. NAME:=Bananapi M2 Ultra
  2608. @@ -402,6 +411,7 @@ UBOOT_TARGETS := \
  2609. orangepi_2 \
  2610. orangepi_pc2 \
  2611. orangepi_zero2 \
  2612. + orangepi_zero3 \
  2613. pangolin \
  2614. pine64_plus \
  2615. Sinovoip_BPI_M3 \
  2616. diff --git a/target/linux/sunxi/cortexa53/config-6.1 b/target/linux/sunxi/cortexa53/config-6.1
  2617. index f57c6645403ce..cac7fff4dc9f5 100644
  2618. --- a/target/linux/sunxi/cortexa53/config-6.1
  2619. +++ b/target/linux/sunxi/cortexa53/config-6.1
  2620. @@ -53,6 +53,7 @@ CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
  2621. CONFIG_MDIO_BUS_MUX=y
  2622. CONFIG_MICREL_PHY=y
  2623. CONFIG_MODULES_USE_ELF_RELA=y
  2624. +CONFIG_MOTORCOMM_PHY=y
  2625. CONFIG_MUSB_PIO_ONLY=y
  2626. CONFIG_NEED_SG_DMA_LENGTH=y
  2627. CONFIG_NOP_USB_XCEIV=y
  2628. diff --git a/target/linux/sunxi/image/cortexa53.mk b/target/linux/sunxi/image/cortexa53.mk
  2629. index 80718b34bf294..63ada59f85faf 100644
  2630. --- a/target/linux/sunxi/image/cortexa53.mk
  2631. +++ b/target/linux/sunxi/image/cortexa53.mk
  2632. @@ -29,6 +29,11 @@ define Device/sun50i-h616
  2633. $(Device/sun50i)
  2634. endef
  2635. +define Device/sun50i-h618
  2636. + SOC := sun50i-h618
  2637. + $(Device/sun50i)
  2638. +endef
  2639. +
  2640. define Device/friendlyarm_nanopi-neo-plus2
  2641. DEVICE_VENDOR := FriendlyARM
  2642. DEVICE_MODEL := NanoPi NEO Plus2
  2643. @@ -120,6 +125,13 @@ define Device/xunlong_orangepi-zero2
  2644. endef
  2645. TARGET_DEVICES += xunlong_orangepi-zero2
  2646. +define Device/xunlong_orangepi-zero3
  2647. + DEVICE_VENDOR := Xunlong
  2648. + DEVICE_MODEL := Orange Pi Zero 3
  2649. + $(Device/sun50i-h618)
  2650. +endef
  2651. +TARGET_DEVICES += xunlong_orangepi-zero3
  2652. +
  2653. define Device/xunlong_orangepi-zero-plus
  2654. DEVICE_VENDOR := Xunlong
  2655. DEVICE_MODEL := Orange Pi Zero Plus
  2656. diff --git a/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch b/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch
  2657. new file mode 100644
  2658. index 0000000000000..0747e6a8e02ed
  2659. --- /dev/null
  2660. +++ b/target/linux/sunxi/patches-6.1/005-v6.6-arm64-dts-allwinner-h616-Split-Orange-Pi-Zero-2-DT.patch
  2661. @@ -0,0 +1,305 @@
  2662. +From 322bf103204b8f786547acbeed85569254e7088f Mon Sep 17 00:00:00 2001
  2663. +From: Andre Przywara <[email protected]>
  2664. +Date: Fri, 4 Aug 2023 18:08:54 +0100
  2665. +Subject: [PATCH] arm64: dts: allwinner: h616: Split Orange Pi Zero 2 DT
  2666. +
  2667. +The Orange Pi Zero 2 got a successor (Zero 3), which shares quite some
  2668. +DT nodes with the Zero 2, but comes with a different PMIC.
  2669. +
  2670. +Move the common parts (except the PMIC) into a new shared file, and
  2671. +include that from the existing board .dts file.
  2672. +
  2673. +No functional change, the generated DTB is the same, except for some
  2674. +phandle numbering differences.
  2675. +
  2676. +Signed-off-by: Andre Przywara <[email protected]>
  2677. +Acked-by: Jernej Skrabec <[email protected]>
  2678. +Link: https://lore.kernel.org/r/[email protected]
  2679. +Signed-off-by: Jernej Skrabec <[email protected]>
  2680. +---
  2681. + .../allwinner/sun50i-h616-orangepi-zero.dtsi | 134 ++++++++++++++++++
  2682. + .../allwinner/sun50i-h616-orangepi-zero2.dts | 119 +---------------
  2683. + 2 files changed, 135 insertions(+), 118 deletions(-)
  2684. + create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi
  2685. +
  2686. +--- /dev/null
  2687. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi
  2688. +@@ -0,0 +1,134 @@
  2689. ++// SPDX-License-Identifier: (GPL-2.0+ or MIT)
  2690. ++/*
  2691. ++ * Copyright (C) 2020 Arm Ltd.
  2692. ++ *
  2693. ++ * DT nodes common between Orange Pi Zero 2 and Orange Pi Zero 3.
  2694. ++ * Excludes PMIC nodes and properties, since they are different between the two.
  2695. ++ */
  2696. ++
  2697. ++#include "sun50i-h616.dtsi"
  2698. ++
  2699. ++#include <dt-bindings/gpio/gpio.h>
  2700. ++#include <dt-bindings/interrupt-controller/arm-gic.h>
  2701. ++#include <dt-bindings/leds/common.h>
  2702. ++
  2703. ++/ {
  2704. ++ aliases {
  2705. ++ ethernet0 = &emac0;
  2706. ++ serial0 = &uart0;
  2707. ++ };
  2708. ++
  2709. ++ chosen {
  2710. ++ stdout-path = "serial0:115200n8";
  2711. ++ };
  2712. ++
  2713. ++ leds {
  2714. ++ compatible = "gpio-leds";
  2715. ++
  2716. ++ led-0 {
  2717. ++ function = LED_FUNCTION_POWER;
  2718. ++ color = <LED_COLOR_ID_RED>;
  2719. ++ gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
  2720. ++ default-state = "on";
  2721. ++ };
  2722. ++
  2723. ++ led-1 {
  2724. ++ function = LED_FUNCTION_STATUS;
  2725. ++ color = <LED_COLOR_ID_GREEN>;
  2726. ++ gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
  2727. ++ };
  2728. ++ };
  2729. ++
  2730. ++ reg_vcc5v: vcc5v {
  2731. ++ /* board wide 5V supply directly from the USB-C socket */
  2732. ++ compatible = "regulator-fixed";
  2733. ++ regulator-name = "vcc-5v";
  2734. ++ regulator-min-microvolt = <5000000>;
  2735. ++ regulator-max-microvolt = <5000000>;
  2736. ++ regulator-always-on;
  2737. ++ };
  2738. ++
  2739. ++ reg_usb1_vbus: regulator-usb1-vbus {
  2740. ++ compatible = "regulator-fixed";
  2741. ++ regulator-name = "usb1-vbus";
  2742. ++ regulator-min-microvolt = <5000000>;
  2743. ++ regulator-max-microvolt = <5000000>;
  2744. ++ vin-supply = <&reg_vcc5v>;
  2745. ++ enable-active-high;
  2746. ++ gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */
  2747. ++ };
  2748. ++};
  2749. ++
  2750. ++&ehci1 {
  2751. ++ status = "okay";
  2752. ++};
  2753. ++
  2754. ++/* USB 2 & 3 are on headers only. */
  2755. ++
  2756. ++&emac0 {
  2757. ++ pinctrl-names = "default";
  2758. ++ pinctrl-0 = <&ext_rgmii_pins>;
  2759. ++ phy-mode = "rgmii";
  2760. ++ phy-handle = <&ext_rgmii_phy>;
  2761. ++ allwinner,rx-delay-ps = <3100>;
  2762. ++ allwinner,tx-delay-ps = <700>;
  2763. ++ status = "okay";
  2764. ++};
  2765. ++
  2766. ++&mdio0 {
  2767. ++ ext_rgmii_phy: ethernet-phy@1 {
  2768. ++ compatible = "ethernet-phy-ieee802.3-c22";
  2769. ++ reg = <1>;
  2770. ++ };
  2771. ++};
  2772. ++
  2773. ++&mmc0 {
  2774. ++ cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
  2775. ++ bus-width = <4>;
  2776. ++ status = "okay";
  2777. ++};
  2778. ++
  2779. ++&ohci1 {
  2780. ++ status = "okay";
  2781. ++};
  2782. ++
  2783. ++&spi0 {
  2784. ++ status = "okay";
  2785. ++ pinctrl-names = "default";
  2786. ++ pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>;
  2787. ++
  2788. ++ flash@0 {
  2789. ++ #address-cells = <1>;
  2790. ++ #size-cells = <1>;
  2791. ++ compatible = "jedec,spi-nor";
  2792. ++ reg = <0>;
  2793. ++ spi-max-frequency = <40000000>;
  2794. ++ };
  2795. ++};
  2796. ++
  2797. ++&uart0 {
  2798. ++ pinctrl-names = "default";
  2799. ++ pinctrl-0 = <&uart0_ph_pins>;
  2800. ++ status = "okay";
  2801. ++};
  2802. ++
  2803. ++&usbotg {
  2804. ++ /*
  2805. ++ * PHY0 pins are connected to a USB-C socket, but a role switch
  2806. ++ * is not implemented: both CC pins are pulled to GND.
  2807. ++ * The VBUS pins power the device, so a fixed peripheral mode
  2808. ++ * is the best choice.
  2809. ++ * The board can be powered via GPIOs, in this case port0 *can*
  2810. ++ * act as a host (with a cable/adapter ignoring CC), as VBUS is
  2811. ++ * then provided by the GPIOs. Any user of this setup would
  2812. ++ * need to adjust the DT accordingly: dr_mode set to "host",
  2813. ++ * enabling OHCI0 and EHCI0.
  2814. ++ */
  2815. ++ dr_mode = "peripheral";
  2816. ++ status = "okay";
  2817. ++};
  2818. ++
  2819. ++&usbphy {
  2820. ++ usb1_vbus-supply = <&reg_usb1_vbus>;
  2821. ++ status = "okay";
  2822. ++};
  2823. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
  2824. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
  2825. +@@ -5,95 +5,19 @@
  2826. +
  2827. + /dts-v1/;
  2828. +
  2829. +-#include "sun50i-h616.dtsi"
  2830. +-
  2831. +-#include <dt-bindings/gpio/gpio.h>
  2832. +-#include <dt-bindings/interrupt-controller/arm-gic.h>
  2833. +-#include <dt-bindings/leds/common.h>
  2834. ++#include "sun50i-h616-orangepi-zero.dtsi"
  2835. +
  2836. + / {
  2837. + model = "OrangePi Zero2";
  2838. + compatible = "xunlong,orangepi-zero2", "allwinner,sun50i-h616";
  2839. +-
  2840. +- aliases {
  2841. +- ethernet0 = &emac0;
  2842. +- serial0 = &uart0;
  2843. +- };
  2844. +-
  2845. +- chosen {
  2846. +- stdout-path = "serial0:115200n8";
  2847. +- };
  2848. +-
  2849. +- leds {
  2850. +- compatible = "gpio-leds";
  2851. +-
  2852. +- led-0 {
  2853. +- function = LED_FUNCTION_POWER;
  2854. +- color = <LED_COLOR_ID_RED>;
  2855. +- gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
  2856. +- default-state = "on";
  2857. +- };
  2858. +-
  2859. +- led-1 {
  2860. +- function = LED_FUNCTION_STATUS;
  2861. +- color = <LED_COLOR_ID_GREEN>;
  2862. +- gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
  2863. +- };
  2864. +- };
  2865. +-
  2866. +- reg_vcc5v: vcc5v {
  2867. +- /* board wide 5V supply directly from the USB-C socket */
  2868. +- compatible = "regulator-fixed";
  2869. +- regulator-name = "vcc-5v";
  2870. +- regulator-min-microvolt = <5000000>;
  2871. +- regulator-max-microvolt = <5000000>;
  2872. +- regulator-always-on;
  2873. +- };
  2874. +-
  2875. +- reg_usb1_vbus: regulator-usb1-vbus {
  2876. +- compatible = "regulator-fixed";
  2877. +- regulator-name = "usb1-vbus";
  2878. +- regulator-min-microvolt = <5000000>;
  2879. +- regulator-max-microvolt = <5000000>;
  2880. +- vin-supply = <&reg_vcc5v>;
  2881. +- enable-active-high;
  2882. +- gpio = <&pio 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */
  2883. +- };
  2884. +-};
  2885. +-
  2886. +-&ehci1 {
  2887. +- status = "okay";
  2888. + };
  2889. +
  2890. +-/* USB 2 & 3 are on headers only. */
  2891. +-
  2892. + &emac0 {
  2893. +- pinctrl-names = "default";
  2894. +- pinctrl-0 = <&ext_rgmii_pins>;
  2895. +- phy-mode = "rgmii";
  2896. +- phy-handle = <&ext_rgmii_phy>;
  2897. + phy-supply = <&reg_dcdce>;
  2898. +- allwinner,rx-delay-ps = <3100>;
  2899. +- allwinner,tx-delay-ps = <700>;
  2900. +- status = "okay";
  2901. +-};
  2902. +-
  2903. +-&mdio0 {
  2904. +- ext_rgmii_phy: ethernet-phy@1 {
  2905. +- compatible = "ethernet-phy-ieee802.3-c22";
  2906. +- reg = <1>;
  2907. +- };
  2908. + };
  2909. +
  2910. + &mmc0 {
  2911. + vmmc-supply = <&reg_dcdce>;
  2912. +- cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
  2913. +- bus-width = <4>;
  2914. +- status = "okay";
  2915. +-};
  2916. +-
  2917. +-&ohci1 {
  2918. +- status = "okay";
  2919. + };
  2920. +
  2921. + &r_rsb {
  2922. +@@ -211,44 +135,3 @@
  2923. + vcc-ph-supply = <&reg_aldo1>;
  2924. + vcc-pi-supply = <&reg_aldo1>;
  2925. + };
  2926. +-
  2927. +-&spi0 {
  2928. +- status = "okay";
  2929. +- pinctrl-names = "default";
  2930. +- pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>;
  2931. +-
  2932. +- flash@0 {
  2933. +- #address-cells = <1>;
  2934. +- #size-cells = <1>;
  2935. +- compatible = "jedec,spi-nor";
  2936. +- reg = <0>;
  2937. +- spi-max-frequency = <40000000>;
  2938. +- };
  2939. +-};
  2940. +-
  2941. +-&uart0 {
  2942. +- pinctrl-names = "default";
  2943. +- pinctrl-0 = <&uart0_ph_pins>;
  2944. +- status = "okay";
  2945. +-};
  2946. +-
  2947. +-&usbotg {
  2948. +- /*
  2949. +- * PHY0 pins are connected to a USB-C socket, but a role switch
  2950. +- * is not implemented: both CC pins are pulled to GND.
  2951. +- * The VBUS pins power the device, so a fixed peripheral mode
  2952. +- * is the best choice.
  2953. +- * The board can be powered via GPIOs, in this case port0 *can*
  2954. +- * act as a host (with a cable/adapter ignoring CC), as VBUS is
  2955. +- * then provided by the GPIOs. Any user of this setup would
  2956. +- * need to adjust the DT accordingly: dr_mode set to "host",
  2957. +- * enabling OHCI0 and EHCI0.
  2958. +- */
  2959. +- dr_mode = "peripheral";
  2960. +- status = "okay";
  2961. +-};
  2962. +-
  2963. +-&usbphy {
  2964. +- usb1_vbus-supply = <&reg_usb1_vbus>;
  2965. +- status = "okay";
  2966. +-};
  2967. diff --git a/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch b/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch
  2968. new file mode 100644
  2969. index 0000000000000..4081a82d52444
  2970. --- /dev/null
  2971. +++ b/target/linux/sunxi/patches-6.1/006-v6.6-arm64-dts-allwinner-h616-Add-OrangePi-Zero-3-board.patch
  2972. @@ -0,0 +1,140 @@
  2973. +From f1b3ddb3ecc2eec1f912383e01156c226daacfab Mon Sep 17 00:00:00 2001
  2974. +From: Andre Przywara <[email protected]>
  2975. +Date: Fri, 4 Aug 2023 18:08:56 +0100
  2976. +Subject: [PATCH] arm64: dts: allwinner: h616: Add OrangePi Zero 3 board
  2977. + support
  2978. +
  2979. +The OrangePi Zero 3 is a development board based on the Allwinner H618 SoC,
  2980. +which seems to be just an H616 with more L2 cache. The board itself is a
  2981. +slightly updated version of the Orange Pi Zero 2. It features:
  2982. +- Four ARM Cortex-A53 cores, Mali-G31 MP2 GPU
  2983. +- 1/1.5/2/4 GiB LPDDR4 DRAM SKUs (only up to 1GB on the Zero2)
  2984. +- AXP313a PMIC (more capable AXP305 on the Zero2)
  2985. +- Raspberry-Pi-1 compatible GPIO header
  2986. +- extra 13 pin expansion header, exposing pins for 2x USB 2.0 ports
  2987. +- 1 USB 2.0 host port
  2988. +- 1 USB 2.0 type C port (power supply + OTG)
  2989. +- MicroSD slot
  2990. +- on-board 16MiB bootable SPI NOR flash (only 2MB on the Zero2)
  2991. +- 1Gbps Ethernet port (via Motorcomm YT8531 PHY) (RTL8211 on the Zero2)
  2992. +- micro-HDMI port
  2993. +- (yet) unsupported Allwinner WiFi/BT chip
  2994. +
  2995. +Add the devicetree file describing the currently supported features,
  2996. +namely LEDs, SD card, PMIC, SPI flash, USB. Ethernet seems unstable at
  2997. +the moment, though the basic functionality works.
  2998. +
  2999. +Signed-off-by: Andre Przywara <[email protected]>
  3000. +Reviewed-by: Jernej Skrabec <[email protected]>
  3001. +Link: https://lore.kernel.org/r/[email protected]
  3002. +Signed-off-by: Jernej Skrabec <[email protected]>
  3003. +---
  3004. + arch/arm64/boot/dts/allwinner/Makefile | 1 +
  3005. + .../allwinner/sun50i-h618-orangepi-zero3.dts | 94 +++++++++++++++++++
  3006. + 2 files changed, 95 insertions(+)
  3007. + create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
  3008. +
  3009. +--- a/arch/arm64/boot/dts/allwinner/Makefile
  3010. ++++ b/arch/arm64/boot/dts/allwinner/Makefile
  3011. +@@ -40,3 +40,4 @@ dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-ta
  3012. + dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-tanix-tx6-mini.dtb
  3013. + dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h616-orangepi-zero2.dtb
  3014. + dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h616-x96-mate.dtb
  3015. ++dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h618-orangepi-zero3.dtb
  3016. +--- /dev/null
  3017. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
  3018. +@@ -0,0 +1,94 @@
  3019. ++// SPDX-License-Identifier: (GPL-2.0+ or MIT)
  3020. ++/*
  3021. ++ * Copyright (C) 2023 Arm Ltd.
  3022. ++ */
  3023. ++
  3024. ++/dts-v1/;
  3025. ++
  3026. ++#include "sun50i-h616-orangepi-zero.dtsi"
  3027. ++
  3028. ++/ {
  3029. ++ model = "OrangePi Zero3";
  3030. ++ compatible = "xunlong,orangepi-zero3", "allwinner,sun50i-h618";
  3031. ++};
  3032. ++
  3033. ++&emac0 {
  3034. ++ phy-supply = <&reg_dldo1>;
  3035. ++};
  3036. ++
  3037. ++&ext_rgmii_phy {
  3038. ++ motorcomm,clk-out-frequency-hz = <125000000>;
  3039. ++};
  3040. ++
  3041. ++&mmc0 {
  3042. ++ /*
  3043. ++ * The schematic shows the card detect pin wired up to PF6, via an
  3044. ++ * inverter, but it just doesn't work.
  3045. ++ */
  3046. ++ broken-cd;
  3047. ++ vmmc-supply = <&reg_dldo1>;
  3048. ++};
  3049. ++
  3050. ++&r_i2c {
  3051. ++ status = "okay";
  3052. ++
  3053. ++ axp313: pmic@36 {
  3054. ++ compatible = "x-powers,axp313a";
  3055. ++ reg = <0x36>;
  3056. ++ #interrupt-cells = <1>;
  3057. ++ interrupt-controller;
  3058. ++ interrupt-parent = <&pio>;
  3059. ++ interrupts = <2 9 IRQ_TYPE_LEVEL_LOW>; /* PC9 */
  3060. ++
  3061. ++ vin1-supply = <&reg_vcc5v>;
  3062. ++ vin2-supply = <&reg_vcc5v>;
  3063. ++ vin3-supply = <&reg_vcc5v>;
  3064. ++
  3065. ++ regulators {
  3066. ++ /* Supplies VCC-PLL, so needs to be always on. */
  3067. ++ reg_aldo1: aldo1 {
  3068. ++ regulator-always-on;
  3069. ++ regulator-min-microvolt = <1800000>;
  3070. ++ regulator-max-microvolt = <1800000>;
  3071. ++ regulator-name = "vcc1v8";
  3072. ++ };
  3073. ++
  3074. ++ /* Supplies VCC-IO, so needs to be always on. */
  3075. ++ reg_dldo1: dldo1 {
  3076. ++ regulator-always-on;
  3077. ++ regulator-min-microvolt = <3300000>;
  3078. ++ regulator-max-microvolt = <3300000>;
  3079. ++ regulator-name = "vcc3v3";
  3080. ++ };
  3081. ++
  3082. ++ reg_dcdc1: dcdc1 {
  3083. ++ regulator-always-on;
  3084. ++ regulator-min-microvolt = <810000>;
  3085. ++ regulator-max-microvolt = <990000>;
  3086. ++ regulator-name = "vdd-gpu-sys";
  3087. ++ };
  3088. ++
  3089. ++ reg_dcdc2: dcdc2 {
  3090. ++ regulator-always-on;
  3091. ++ regulator-min-microvolt = <810000>;
  3092. ++ regulator-max-microvolt = <1100000>;
  3093. ++ regulator-name = "vdd-cpu";
  3094. ++ };
  3095. ++
  3096. ++ reg_dcdc3: dcdc3 {
  3097. ++ regulator-always-on;
  3098. ++ regulator-min-microvolt = <1100000>;
  3099. ++ regulator-max-microvolt = <1100000>;
  3100. ++ regulator-name = "vdd-dram";
  3101. ++ };
  3102. ++ };
  3103. ++ };
  3104. ++};
  3105. ++
  3106. ++&pio {
  3107. ++ vcc-pc-supply = <&reg_dldo1>;
  3108. ++ vcc-pf-supply = <&reg_dldo1>;
  3109. ++ vcc-pg-supply = <&reg_aldo1>;
  3110. ++ vcc-ph-supply = <&reg_dldo1>;
  3111. ++ vcc-pi-supply = <&reg_dldo1>;
  3112. ++};
  3113. diff --git a/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch b/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch
  3114. new file mode 100644
  3115. index 0000000000000..a492eed551247
  3116. --- /dev/null
  3117. +++ b/target/linux/sunxi/patches-6.1/007-v6.7-arm64-dts-allwinner-h616-update-emac-for-Orange-Pi.patch
  3118. @@ -0,0 +1,57 @@
  3119. +From b9622937d95809ef89904583191571a9fa326402 Mon Sep 17 00:00:00 2001
  3120. +From: Chukun Pan <[email protected]>
  3121. +Date: Sun, 29 Oct 2023 15:40:09 +0800
  3122. +Subject: [PATCH] arm64: dts: allwinner: h616: update emac for Orange Pi Zero 3
  3123. +
  3124. +The current emac setting is not suitable for Orange Pi Zero 3,
  3125. +move it back to Orange Pi Zero 2 DT. Also update phy mode and
  3126. +delay values for emac on Orange Pi Zero 3.
  3127. +With these changes, Ethernet now looks stable.
  3128. +
  3129. +Fixes: 322bf103204b ("arm64: dts: allwinner: h616: Split Orange Pi Zero 2 DT")
  3130. +Signed-off-by: Chukun Pan <[email protected]>
  3131. +Reviewed-by: Jernej Skrabec <[email protected]>
  3132. +Link: https://lore.kernel.org/r/[email protected]
  3133. +Signed-off-by: Jernej Skrabec <[email protected]>
  3134. +---
  3135. + arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi | 3 ---
  3136. + arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts | 3 +++
  3137. + arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts | 2 ++
  3138. + 3 files changed, 5 insertions(+), 3 deletions(-)
  3139. +
  3140. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi
  3141. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero.dtsi
  3142. +@@ -68,10 +68,7 @@
  3143. + &emac0 {
  3144. + pinctrl-names = "default";
  3145. + pinctrl-0 = <&ext_rgmii_pins>;
  3146. +- phy-mode = "rgmii";
  3147. + phy-handle = <&ext_rgmii_phy>;
  3148. +- allwinner,rx-delay-ps = <3100>;
  3149. +- allwinner,tx-delay-ps = <700>;
  3150. + status = "okay";
  3151. + };
  3152. +
  3153. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
  3154. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
  3155. +@@ -13,6 +13,9 @@
  3156. + };
  3157. +
  3158. + &emac0 {
  3159. ++ allwinner,rx-delay-ps = <3100>;
  3160. ++ allwinner,tx-delay-ps = <700>;
  3161. ++ phy-mode = "rgmii";
  3162. + phy-supply = <&reg_dcdce>;
  3163. + };
  3164. +
  3165. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
  3166. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h618-orangepi-zero3.dts
  3167. +@@ -13,6 +13,8 @@
  3168. + };
  3169. +
  3170. + &emac0 {
  3171. ++ allwinner,tx-delay-ps = <700>;
  3172. ++ phy-mode = "rgmii-rxid";
  3173. + phy-supply = <&reg_dldo1>;
  3174. + };
  3175. +
  3176. From 601a80db2a3846adbc715e1ef3d3da1c156290a3 Mon Sep 17 00:00:00 2001
  3177. From: Chukun Pan <[email protected]>
  3178. Date: Wed, 6 Mar 2024 23:10:21 +0800
  3179. Subject: [PATCH 4/4] sunxi: backport h616 thermal sensor support
  3180. Backport H616 thermal sensor support from linux-next.
  3181. Tested on the Orange Pi Zero 3 (H618 SoC).
  3182. Signed-off-by: Chukun Pan <[email protected]>
  3183. ---
  3184. ...lwinner-h616-Add-SID-controller-node.patch | 31 ++++
  3185. ...am-export-register-0-for-THS-on-H616.patch | 98 +++++++++++++
  3186. ...-Add-D1-T113s-THS-controller-support.patch | 47 ++++++
  3187. ...8i-Explain-unknown-H6-register-value.patch | 79 ++++++++++
  3188. ...i-Extend-H6-calibration-to-support-4.patch | 74 ++++++++++
  3189. ...-sun8i-Add-SRAM-register-access-code.patch | 126 ++++++++++++++++
  3190. ...-Add-support-for-H616-THS-controller.patch | 50 +++++++
  3191. ...Dont-fail-probe-due-to-zone-registra.patch | 68 +++++++++
  3192. ...er-h616-Add-thermal-sensor-and-zones.patch | 138 ++++++++++++++++++
  3193. 9 files changed, 711 insertions(+)
  3194. create mode 100644 target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch
  3195. create mode 100644 target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch
  3196. create mode 100644 target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch
  3197. create mode 100644 target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch
  3198. create mode 100644 target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch
  3199. create mode 100644 target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch
  3200. create mode 100644 target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch
  3201. create mode 100644 target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch
  3202. create mode 100644 target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch
  3203. diff --git a/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch b/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch
  3204. new file mode 100644
  3205. index 0000000000000..ce8add18ab434
  3206. --- /dev/null
  3207. +++ b/target/linux/sunxi/patches-6.1/008-v6.7-arm64-dts-allwinner-h616-Add-SID-controller-node.patch
  3208. @@ -0,0 +1,31 @@
  3209. +From 951992797378a2177946400438f4d23c9fceae5b Mon Sep 17 00:00:00 2001
  3210. +From: Martin Botka <[email protected]>
  3211. +Date: Tue, 12 Sep 2023 14:25:13 +0200
  3212. +Subject: [PATCH] arm64: dts: allwinner: h616: Add SID controller node
  3213. +
  3214. +Add node for the H616 SID controller
  3215. +
  3216. +Signed-off-by: Martin Botka <[email protected]>
  3217. +Acked-by: Jernej Skrabec <[email protected]>
  3218. +Link: https://lore.kernel.org/r/[email protected]
  3219. +Signed-off-by: Jernej Skrabec <[email protected]>
  3220. +---
  3221. + arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 7 +++++++
  3222. + 1 file changed, 7 insertions(+)
  3223. +
  3224. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
  3225. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
  3226. +@@ -133,6 +133,13 @@
  3227. + #reset-cells = <1>;
  3228. + };
  3229. +
  3230. ++ sid: efuse@3006000 {
  3231. ++ compatible = "allwinner,sun50i-h616-sid", "allwinner,sun50i-a64-sid";
  3232. ++ reg = <0x03006000 0x1000>;
  3233. ++ #address-cells = <1>;
  3234. ++ #size-cells = <1>;
  3235. ++ };
  3236. ++
  3237. + watchdog: watchdog@30090a0 {
  3238. + compatible = "allwinner,sun50i-h616-wdt",
  3239. + "allwinner,sun6i-a31-wdt";
  3240. diff --git a/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch b/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch
  3241. new file mode 100644
  3242. index 0000000000000..3453e2aa5330f
  3243. --- /dev/null
  3244. +++ b/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch
  3245. @@ -0,0 +1,98 @@
  3246. +From 898d96c5464b69af44f6407c5de81ebc349d574b Mon Sep 17 00:00:00 2001
  3247. +From: Andre Przywara <[email protected]>
  3248. +Date: Mon, 19 Feb 2024 15:36:33 +0000
  3249. +Subject: [PATCH] soc: sunxi: sram: export register 0 for THS on H616
  3250. +
  3251. +The Allwinner H616 SoC contains a mysterious bit at register offset 0x0
  3252. +in the SRAM control block. If bit 16 is set (the reset value), the
  3253. +temperature readings of the THS are way off, leading to reports about
  3254. +200C, at normal ambient temperatures. Clearing this bits brings the
  3255. +reported values down to the expected values.
  3256. +The BSP code clears this bit in firmware (U-Boot), and has an explicit
  3257. +comment about this, but offers no real explanation.
  3258. +
  3259. +Experiments in U-Boot show that register 0x0 has no effect on the SRAM C
  3260. +visibility: all tested bit settings still allow full read and write
  3261. +access by the CPU to the whole of SRAM C. Only bit 24 of the register at
  3262. +offset 0x4 makes all of SRAM C inaccessible by the CPU. So modelling
  3263. +the THS switch functionality as an SRAM region would not reflect reality.
  3264. +
  3265. +Since we should not rely on firmware settings, allow other code (the THS
  3266. +driver) to access this register, by exporting it through the already
  3267. +existing regmap. This mimics what we already do for the LDO control and
  3268. +the EMAC register.
  3269. +
  3270. +To avoid concurrent accesses to the same register at the same time, by
  3271. +the SRAM switch code and the regmap code, use the same lock to protect
  3272. +the access. The regmap subsystem allows to use an existing lock, so we
  3273. +just need to hook in there.
  3274. +
  3275. +Signed-off-by: Andre Przywara <[email protected]>
  3276. +Reviewed-by: Jernej Skrabec <[email protected]>
  3277. +Signed-off-by: Daniel Lezcano <[email protected]>
  3278. +Link: https://lore.kernel.org/r/[email protected]
  3279. +---
  3280. + drivers/soc/sunxi/sunxi_sram.c | 22 ++++++++++++++++++++++
  3281. + 1 file changed, 22 insertions(+)
  3282. +
  3283. +--- a/drivers/soc/sunxi/sunxi_sram.c
  3284. ++++ b/drivers/soc/sunxi/sunxi_sram.c
  3285. +@@ -284,6 +284,7 @@ EXPORT_SYMBOL(sunxi_sram_release);
  3286. + struct sunxi_sramc_variant {
  3287. + int num_emac_clocks;
  3288. + bool has_ldo_ctrl;
  3289. ++ bool has_ths_offset;
  3290. + };
  3291. +
  3292. + static const struct sunxi_sramc_variant sun4i_a10_sramc_variant = {
  3293. +@@ -305,8 +306,10 @@ static const struct sunxi_sramc_variant
  3294. +
  3295. + static const struct sunxi_sramc_variant sun50i_h616_sramc_variant = {
  3296. + .num_emac_clocks = 2,
  3297. ++ .has_ths_offset = true,
  3298. + };
  3299. +
  3300. ++#define SUNXI_SRAM_THS_OFFSET_REG 0x0
  3301. + #define SUNXI_SRAM_EMAC_CLOCK_REG 0x30
  3302. + #define SUNXI_SYS_LDO_CTRL_REG 0x150
  3303. +
  3304. +@@ -315,6 +318,8 @@ static bool sunxi_sram_regmap_accessible
  3305. + {
  3306. + const struct sunxi_sramc_variant *variant = dev_get_drvdata(dev);
  3307. +
  3308. ++ if (reg == SUNXI_SRAM_THS_OFFSET_REG && variant->has_ths_offset)
  3309. ++ return true;
  3310. + if (reg >= SUNXI_SRAM_EMAC_CLOCK_REG &&
  3311. + reg < SUNXI_SRAM_EMAC_CLOCK_REG + variant->num_emac_clocks * 4)
  3312. + return true;
  3313. +@@ -324,6 +329,20 @@ static bool sunxi_sram_regmap_accessible
  3314. + return false;
  3315. + }
  3316. +
  3317. ++static void sunxi_sram_lock(void *_lock)
  3318. ++{
  3319. ++ spinlock_t *lock = _lock;
  3320. ++
  3321. ++ spin_lock(lock);
  3322. ++}
  3323. ++
  3324. ++static void sunxi_sram_unlock(void *_lock)
  3325. ++{
  3326. ++ spinlock_t *lock = _lock;
  3327. ++
  3328. ++ spin_unlock(lock);
  3329. ++}
  3330. ++
  3331. + static struct regmap_config sunxi_sram_regmap_config = {
  3332. + .reg_bits = 32,
  3333. + .val_bits = 32,
  3334. +@@ -333,6 +352,9 @@ static struct regmap_config sunxi_sram_r
  3335. + /* other devices have no business accessing other registers */
  3336. + .readable_reg = sunxi_sram_regmap_accessible_reg,
  3337. + .writeable_reg = sunxi_sram_regmap_accessible_reg,
  3338. ++ .lock = sunxi_sram_lock,
  3339. ++ .unlock = sunxi_sram_unlock,
  3340. ++ .lock_arg = &sram_lock,
  3341. + };
  3342. +
  3343. + static int __init sunxi_sram_probe(struct platform_device *pdev)
  3344. diff --git a/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch b/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch
  3345. new file mode 100644
  3346. index 0000000000000..8b199891184fe
  3347. --- /dev/null
  3348. +++ b/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch
  3349. @@ -0,0 +1,47 @@
  3350. +From ebbf19e36d021f253425344b4d4b987f3b7d9be5 Mon Sep 17 00:00:00 2001
  3351. +From: Maxim Kiselev <[email protected]>
  3352. +Date: Mon, 18 Dec 2023 00:06:23 +0300
  3353. +Subject: [PATCH] thermal/drivers/sun8i: Add D1/T113s THS controller support
  3354. +
  3355. +This patch adds a thermal sensor controller support for the D1/T113s,
  3356. +which is similar to the one on H6, but with only one sensor and
  3357. +different scale and offset values.
  3358. +
  3359. +Signed-off-by: Maxim Kiselev <[email protected]>
  3360. +Acked-by: Jernej Skrabec <[email protected]>
  3361. +Reviewed-by: Andre Przywara <[email protected]>
  3362. +Signed-off-by: Daniel Lezcano <[email protected]>
  3363. +Link: https://lore.kernel.org/r/[email protected]
  3364. +---
  3365. + drivers/thermal/sun8i_thermal.c | 13 +++++++++++++
  3366. + 1 file changed, 13 insertions(+)
  3367. +
  3368. +--- a/drivers/thermal/sun8i_thermal.c
  3369. ++++ b/drivers/thermal/sun8i_thermal.c
  3370. +@@ -610,6 +610,18 @@ static const struct ths_thermal_chip sun
  3371. + .calc_temp = sun8i_ths_calc_temp,
  3372. + };
  3373. +
  3374. ++static const struct ths_thermal_chip sun20i_d1_ths = {
  3375. ++ .sensor_num = 1,
  3376. ++ .has_bus_clk_reset = true,
  3377. ++ .offset = 188552,
  3378. ++ .scale = 673,
  3379. ++ .temp_data_base = SUN50I_H6_THS_TEMP_DATA,
  3380. ++ .calibrate = sun50i_h6_ths_calibrate,
  3381. ++ .init = sun50i_h6_thermal_init,
  3382. ++ .irq_ack = sun50i_h6_irq_ack,
  3383. ++ .calc_temp = sun8i_ths_calc_temp,
  3384. ++};
  3385. ++
  3386. + static const struct of_device_id of_ths_match[] = {
  3387. + { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths },
  3388. + { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths },
  3389. +@@ -618,6 +630,7 @@ static const struct of_device_id of_ths_
  3390. + { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths },
  3391. + { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths },
  3392. + { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths },
  3393. ++ { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths },
  3394. + { /* sentinel */ },
  3395. + };
  3396. + MODULE_DEVICE_TABLE(of, of_ths_match);
  3397. diff --git a/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch b/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch
  3398. new file mode 100644
  3399. index 0000000000000..b8138a3870375
  3400. --- /dev/null
  3401. +++ b/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch
  3402. @@ -0,0 +1,79 @@
  3403. +From 14f118aa50fe7c7c7330f56d007ecacca487cea8 Mon Sep 17 00:00:00 2001
  3404. +From: Andre Przywara <[email protected]>
  3405. +Date: Mon, 19 Feb 2024 15:36:35 +0000
  3406. +Subject: [PATCH] thermal/drivers/sun8i: Explain unknown H6 register value
  3407. +
  3408. +So far we were ORing in some "unknown" value into the THS control
  3409. +register on the Allwinner H6. This part of the register is not explained
  3410. +in the H6 manual, but the H616 manual details those bits, and on closer
  3411. +inspection the THS IP blocks in both SoCs seem very close:
  3412. +- The BSP code for both SoCs writes the same values into THS_CTRL.
  3413. +- The reset values of at least the first three registers are the same.
  3414. +
  3415. +Replace the "unknown" value with its proper meaning: "acquire time",
  3416. +most probably the sample part of the sample & hold circuit of the ADC,
  3417. +according to its explanation in the H616 manual.
  3418. +
  3419. +No functional change, just a macro rename and adjustment.
  3420. +
  3421. +Signed-off-by: Andre Przywara <[email protected]>
  3422. +Reviewed-by: Jernej Skrabec <[email protected]>
  3423. +Acked-by: Vasily Khoruzhick <[email protected]>
  3424. +Signed-off-by: Daniel Lezcano <[email protected]>
  3425. +Link: https://lore.kernel.org/r/[email protected]
  3426. +---
  3427. + drivers/thermal/sun8i_thermal.c | 29 ++++++++++++++++-------------
  3428. + 1 file changed, 16 insertions(+), 13 deletions(-)
  3429. +
  3430. +--- a/drivers/thermal/sun8i_thermal.c
  3431. ++++ b/drivers/thermal/sun8i_thermal.c
  3432. +@@ -50,7 +50,8 @@
  3433. + #define SUN8I_THS_CTRL2_T_ACQ1(x) ((GENMASK(15, 0) & (x)) << 16)
  3434. + #define SUN8I_THS_DATA_IRQ_STS(x) BIT(x + 8)
  3435. +
  3436. +-#define SUN50I_THS_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16)
  3437. ++#define SUN50I_THS_CTRL0_T_ACQ(x) (GENMASK(15, 0) & ((x) - 1))
  3438. ++#define SUN50I_THS_CTRL0_T_SAMPLE_PER(x) ((GENMASK(15, 0) & ((x) - 1)) << 16)
  3439. + #define SUN50I_THS_FILTER_EN BIT(2)
  3440. + #define SUN50I_THS_FILTER_TYPE(x) (GENMASK(1, 0) & (x))
  3441. + #define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12)
  3442. +@@ -410,25 +411,27 @@ static int sun8i_h3_thermal_init(struct
  3443. + return 0;
  3444. + }
  3445. +
  3446. +-/*
  3447. +- * Without this undocumented value, the returned temperatures would
  3448. +- * be higher than real ones by about 20C.
  3449. +- */
  3450. +-#define SUN50I_H6_CTRL0_UNK 0x0000002f
  3451. +-
  3452. + static int sun50i_h6_thermal_init(struct ths_device *tmdev)
  3453. + {
  3454. + int val;
  3455. +
  3456. + /*
  3457. +- * T_acq = 20us
  3458. +- * clkin = 24MHz
  3459. +- *
  3460. +- * x = T_acq * clkin - 1
  3461. +- * = 479
  3462. ++ * The manual recommends an overall sample frequency of 50 KHz (20us,
  3463. ++ * 480 cycles at 24 MHz), which provides plenty of time for both the
  3464. ++ * acquisition time (>24 cycles) and the actual conversion time
  3465. ++ * (>14 cycles).
  3466. ++ * The lower half of the CTRL register holds the "acquire time", in
  3467. ++ * clock cycles, which the manual recommends to be 2us:
  3468. ++ * 24MHz * 2us = 48 cycles.
  3469. ++ * The high half of THS_CTRL encodes the sample frequency, in clock
  3470. ++ * cycles: 24MHz * 20us = 480 cycles.
  3471. ++ * This is explained in the H616 manual, but apparently wrongly
  3472. ++ * described in the H6 manual, although the BSP code does the same
  3473. ++ * for both SoCs.
  3474. + */
  3475. + regmap_write(tmdev->regmap, SUN50I_THS_CTRL0,
  3476. +- SUN50I_H6_CTRL0_UNK | SUN50I_THS_CTRL0_T_ACQ(479));
  3477. ++ SUN50I_THS_CTRL0_T_ACQ(48) |
  3478. ++ SUN50I_THS_CTRL0_T_SAMPLE_PER(480));
  3479. + /* average over 4 samples */
  3480. + regmap_write(tmdev->regmap, SUN50I_H6_THS_MFC,
  3481. + SUN50I_THS_FILTER_EN |
  3482. diff --git a/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch b/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch
  3483. new file mode 100644
  3484. index 0000000000000..3d01a507fac39
  3485. --- /dev/null
  3486. +++ b/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch
  3487. @@ -0,0 +1,74 @@
  3488. +From 6c04a419a4c5fb18edefc44dd676fb95c7f6c55d Mon Sep 17 00:00:00 2001
  3489. +From: Maksim Kiselev <[email protected]>
  3490. +Date: Mon, 19 Feb 2024 15:36:36 +0000
  3491. +Subject: [PATCH] thermal/drivers/sun8i: Extend H6 calibration to support 4
  3492. + sensors
  3493. +
  3494. +The H616 SoC resembles the H6 thermal sensor controller, with a few
  3495. +changes like four sensors.
  3496. +
  3497. +Extend sun50i_h6_ths_calibrate() function to support calibration of
  3498. +these sensors.
  3499. +
  3500. +Co-developed-by: Martin Botka <[email protected]>
  3501. +Signed-off-by: Martin Botka <[email protected]>
  3502. +Signed-off-by: Maksim Kiselev <[email protected]>
  3503. +Reviewed-by: Andre Przywara <[email protected]>
  3504. +Signed-off-by: Andre Przywara <[email protected]>
  3505. +Reviewed-by: Jernej Skrabec <[email protected]>
  3506. +Acked-by: Vasily Khoruzhick <[email protected]>
  3507. +Signed-off-by: Daniel Lezcano <[email protected]>
  3508. +Link: https://lore.kernel.org/r/[email protected]
  3509. +---
  3510. + drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++--------
  3511. + 1 file changed, 20 insertions(+), 8 deletions(-)
  3512. +
  3513. +--- a/drivers/thermal/sun8i_thermal.c
  3514. ++++ b/drivers/thermal/sun8i_thermal.c
  3515. +@@ -224,16 +224,21 @@ static int sun50i_h6_ths_calibrate(struc
  3516. + struct device *dev = tmdev->dev;
  3517. + int i, ft_temp;
  3518. +
  3519. +- if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num)
  3520. ++ if (!caldata[0])
  3521. + return -EINVAL;
  3522. +
  3523. + /*
  3524. + * efuse layout:
  3525. + *
  3526. +- * 0 11 16 32
  3527. +- * +-------+-------+-------+
  3528. +- * |temp| |sensor0|sensor1|
  3529. +- * +-------+-------+-------+
  3530. ++ * 0 11 16 27 32 43 48 57
  3531. ++ * +----------+-----------+-----------+-----------+
  3532. ++ * | temp | |sensor0| |sensor1| |sensor2| |
  3533. ++ * +----------+-----------+-----------+-----------+
  3534. ++ * ^ ^ ^
  3535. ++ * | | |
  3536. ++ * | | sensor3[11:8]
  3537. ++ * | sensor3[7:4]
  3538. ++ * sensor3[3:0]
  3539. + *
  3540. + * The calibration data on the H6 is the ambient temperature and
  3541. + * sensor values that are filled during the factory test stage.
  3542. +@@ -246,9 +251,16 @@ static int sun50i_h6_ths_calibrate(struc
  3543. + ft_temp = (caldata[0] & FT_TEMP_MASK) * 100;
  3544. +
  3545. + for (i = 0; i < tmdev->chip->sensor_num; i++) {
  3546. +- int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
  3547. +- int cdata, offset;
  3548. +- int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
  3549. ++ int sensor_reg, sensor_temp, cdata, offset;
  3550. ++
  3551. ++ if (i == 3)
  3552. ++ sensor_reg = (caldata[1] >> 12)
  3553. ++ | ((caldata[2] >> 12) << 4)
  3554. ++ | ((caldata[3] >> 12) << 8);
  3555. ++ else
  3556. ++ sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
  3557. ++
  3558. ++ sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
  3559. +
  3560. + /*
  3561. + * Calibration data is CALIBRATE_DEFAULT - (calculated
  3562. diff --git a/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch b/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch
  3563. new file mode 100644
  3564. index 0000000000000..6db1e32cfb5a3
  3565. --- /dev/null
  3566. +++ b/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch
  3567. @@ -0,0 +1,126 @@
  3568. +From f8b54d1120b81ed57bed96cc8e814ba08886d1e5 Mon Sep 17 00:00:00 2001
  3569. +From: Andre Przywara <[email protected]>
  3570. +Date: Mon, 19 Feb 2024 15:36:37 +0000
  3571. +Subject: [PATCH] thermal/drivers/sun8i: Add SRAM register access code
  3572. +
  3573. +The Allwinner H616 SoC needs to clear a bit in one register in the SRAM
  3574. +controller, to report reasonable temperature values. On reset, bit 16 in
  3575. +register 0x3000000 is set, which leads to the driver reporting
  3576. +temperatures around 200C. Clearing this bit brings the values down to the
  3577. +expected range. The BSP code does a one-time write in U-Boot, with a
  3578. +comment just mentioning the effect on the THS, but offering no further
  3579. +explanation.
  3580. +
  3581. +To not rely on firmware to set things up for us, add code that queries
  3582. +the SRAM controller device via a DT phandle link, then clear just this
  3583. +single bit.
  3584. +
  3585. +Signed-off-by: Andre Przywara <[email protected]>
  3586. +Acked-by: Vasily Khoruzhick <[email protected]>
  3587. +Signed-off-by: Daniel Lezcano <[email protected]>
  3588. +Link: https://lore.kernel.org/r/[email protected]
  3589. +---
  3590. + drivers/thermal/sun8i_thermal.c | 51 +++++++++++++++++++++++++++++++++
  3591. + 1 file changed, 51 insertions(+)
  3592. +
  3593. +--- a/drivers/thermal/sun8i_thermal.c
  3594. ++++ b/drivers/thermal/sun8i_thermal.c
  3595. +@@ -15,6 +15,7 @@
  3596. + #include <linux/module.h>
  3597. + #include <linux/nvmem-consumer.h>
  3598. + #include <linux/of_device.h>
  3599. ++#include <linux/of_platform.h>
  3600. + #include <linux/platform_device.h>
  3601. + #include <linux/regmap.h>
  3602. + #include <linux/reset.h>
  3603. +@@ -68,6 +69,7 @@ struct tsensor {
  3604. + struct ths_thermal_chip {
  3605. + bool has_mod_clk;
  3606. + bool has_bus_clk_reset;
  3607. ++ bool needs_sram;
  3608. + int sensor_num;
  3609. + int offset;
  3610. + int scale;
  3611. +@@ -85,12 +87,16 @@ struct ths_device {
  3612. + const struct ths_thermal_chip *chip;
  3613. + struct device *dev;
  3614. + struct regmap *regmap;
  3615. ++ struct regmap_field *sram_regmap_field;
  3616. + struct reset_control *reset;
  3617. + struct clk *bus_clk;
  3618. + struct clk *mod_clk;
  3619. + struct tsensor sensor[MAX_SENSOR_NUM];
  3620. + };
  3621. +
  3622. ++/* The H616 needs to have a bit 16 in the SRAM control register cleared. */
  3623. ++static const struct reg_field sun8i_ths_sram_reg_field = REG_FIELD(0x0, 16, 16);
  3624. ++
  3625. + /* Temp Unit: millidegree Celsius */
  3626. + static int sun8i_ths_calc_temp(struct ths_device *tmdev,
  3627. + int id, int reg)
  3628. +@@ -337,6 +343,34 @@ static void sun8i_ths_reset_control_asse
  3629. + reset_control_assert(data);
  3630. + }
  3631. +
  3632. ++static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
  3633. ++{
  3634. ++ struct device_node *sram_node;
  3635. ++ struct platform_device *sram_pdev;
  3636. ++ struct regmap *regmap = NULL;
  3637. ++
  3638. ++ sram_node = of_parse_phandle(node, "allwinner,sram", 0);
  3639. ++ if (!sram_node)
  3640. ++ return ERR_PTR(-ENODEV);
  3641. ++
  3642. ++ sram_pdev = of_find_device_by_node(sram_node);
  3643. ++ if (!sram_pdev) {
  3644. ++ /* platform device might not be probed yet */
  3645. ++ regmap = ERR_PTR(-EPROBE_DEFER);
  3646. ++ goto out_put_node;
  3647. ++ }
  3648. ++
  3649. ++ /* If no regmap is found then the other device driver is at fault */
  3650. ++ regmap = dev_get_regmap(&sram_pdev->dev, NULL);
  3651. ++ if (!regmap)
  3652. ++ regmap = ERR_PTR(-EINVAL);
  3653. ++
  3654. ++ platform_device_put(sram_pdev);
  3655. ++out_put_node:
  3656. ++ of_node_put(sram_node);
  3657. ++ return regmap;
  3658. ++}
  3659. ++
  3660. + static int sun8i_ths_resource_init(struct ths_device *tmdev)
  3661. + {
  3662. + struct device *dev = tmdev->dev;
  3663. +@@ -381,6 +415,19 @@ static int sun8i_ths_resource_init(struc
  3664. + if (ret)
  3665. + return ret;
  3666. +
  3667. ++ if (tmdev->chip->needs_sram) {
  3668. ++ struct regmap *regmap;
  3669. ++
  3670. ++ regmap = sun8i_ths_get_sram_regmap(dev->of_node);
  3671. ++ if (IS_ERR(regmap))
  3672. ++ return PTR_ERR(regmap);
  3673. ++ tmdev->sram_regmap_field = devm_regmap_field_alloc(dev,
  3674. ++ regmap,
  3675. ++ sun8i_ths_sram_reg_field);
  3676. ++ if (IS_ERR(tmdev->sram_regmap_field))
  3677. ++ return PTR_ERR(tmdev->sram_regmap_field);
  3678. ++ }
  3679. ++
  3680. + ret = sun8i_ths_calibrate(tmdev);
  3681. + if (ret)
  3682. + return ret;
  3683. +@@ -427,6 +474,10 @@ static int sun50i_h6_thermal_init(struct
  3684. + {
  3685. + int val;
  3686. +
  3687. ++ /* The H616 needs to have a bit in the SRAM control register cleared. */
  3688. ++ if (tmdev->sram_regmap_field)
  3689. ++ regmap_field_write(tmdev->sram_regmap_field, 0);
  3690. ++
  3691. + /*
  3692. + * The manual recommends an overall sample frequency of 50 KHz (20us,
  3693. + * 480 cycles at 24 MHz), which provides plenty of time for both the
  3694. diff --git a/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch b/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch
  3695. new file mode 100644
  3696. index 0000000000000..e743d344c6e97
  3697. --- /dev/null
  3698. +++ b/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch
  3699. @@ -0,0 +1,50 @@
  3700. +From e7dbfa19572a1440a2e67ef70f94ff204849a0a8 Mon Sep 17 00:00:00 2001
  3701. +From: Martin Botka <[email protected]>
  3702. +Date: Mon, 19 Feb 2024 15:36:38 +0000
  3703. +Subject: [PATCH] thermal/drivers/sun8i: Add support for H616 THS controller
  3704. +
  3705. +Add support for the thermal sensor found in H616 SoCs, is the same as
  3706. +the H6 thermal sensor controller, but with four sensors.
  3707. +Also the registers readings are wrong, unless a bit in the first SYS_CFG
  3708. +register cleared, so set exercise the SRAM regmap to take care of that.
  3709. +
  3710. +Signed-off-by: Martin Botka <[email protected]>
  3711. +Signed-off-by: Andre Przywara <[email protected]>
  3712. +Acked-by: Vasily Khoruzhick <[email protected]>
  3713. +Signed-off-by: Daniel Lezcano <[email protected]>
  3714. +Link: https://lore.kernel.org/r/[email protected]
  3715. +---
  3716. + drivers/thermal/sun8i_thermal.c | 15 +++++++++++++++
  3717. + 1 file changed, 15 insertions(+)
  3718. +
  3719. +--- a/drivers/thermal/sun8i_thermal.c
  3720. ++++ b/drivers/thermal/sun8i_thermal.c
  3721. +@@ -688,6 +688,20 @@ static const struct ths_thermal_chip sun
  3722. + .calc_temp = sun8i_ths_calc_temp,
  3723. + };
  3724. +
  3725. ++static const struct ths_thermal_chip sun50i_h616_ths = {
  3726. ++ .sensor_num = 4,
  3727. ++ .has_bus_clk_reset = true,
  3728. ++ .needs_sram = true,
  3729. ++ .ft_deviation = 8000,
  3730. ++ .offset = 263655,
  3731. ++ .scale = 810,
  3732. ++ .temp_data_base = SUN50I_H6_THS_TEMP_DATA,
  3733. ++ .calibrate = sun50i_h6_ths_calibrate,
  3734. ++ .init = sun50i_h6_thermal_init,
  3735. ++ .irq_ack = sun50i_h6_irq_ack,
  3736. ++ .calc_temp = sun8i_ths_calc_temp,
  3737. ++};
  3738. ++
  3739. + static const struct of_device_id of_ths_match[] = {
  3740. + { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths },
  3741. + { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths },
  3742. +@@ -697,6 +711,7 @@ static const struct of_device_id of_ths_
  3743. + { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths },
  3744. + { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths },
  3745. + { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths },
  3746. ++ { .compatible = "allwinner,sun50i-h616-ths", .data = &sun50i_h616_ths },
  3747. + { /* sentinel */ },
  3748. + };
  3749. + MODULE_DEVICE_TABLE(of, of_ths_match);
  3750. diff --git a/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch b/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch
  3751. new file mode 100644
  3752. index 0000000000000..384bf55084f30
  3753. --- /dev/null
  3754. +++ b/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch
  3755. @@ -0,0 +1,68 @@
  3756. +From 9ac53d5532cc4bb595bbee86ccba2172ccc336c3 Mon Sep 17 00:00:00 2001
  3757. +From: Mark Brown <[email protected]>
  3758. +Date: Tue, 23 Jan 2024 23:33:07 +0000
  3759. +Subject: [PATCH] thermal/drivers/sun8i: Don't fail probe due to zone
  3760. + registration failure
  3761. +
  3762. +Currently the sun8i thermal driver will fail to probe if any of the
  3763. +thermal zones it is registering fails to register with the thermal core.
  3764. +Since we currently do not define any trip points for the GPU thermal
  3765. +zones on at least A64 or H5 this means that we have no thermal support
  3766. +on these platforms:
  3767. +
  3768. +[ 1.698703] thermal_sys: Failed to find 'trips' node
  3769. +[ 1.698707] thermal_sys: Failed to find trip points for thermal-sensor id=1
  3770. +
  3771. +even though the main CPU thermal zone on both SoCs is fully configured.
  3772. +This does not seem ideal, while we may not be able to use all the zones
  3773. +it seems better to have those zones which are usable be operational.
  3774. +Instead just carry on registering zones if we get any non-deferral
  3775. +error, allowing use of those zones which are usable.
  3776. +
  3777. +This means that we also need to update the interrupt handler to not
  3778. +attempt to notify the core for events on zones which we have not
  3779. +registered, I didn't see an ability to mask individual interrupts and
  3780. +I would expect that interrupts would still be indicated in the ISR even
  3781. +if they were masked.
  3782. +
  3783. +Reviewed-by: Vasily Khoruzhick <[email protected]>
  3784. +Acked-by: Jernej Skrabec <[email protected]>
  3785. +Signed-off-by: Mark Brown <[email protected]>
  3786. +Signed-off-by: Daniel Lezcano <[email protected]>
  3787. +Link: https://lore.kernel.org/r/[email protected]
  3788. +---
  3789. + drivers/thermal/sun8i_thermal.c | 16 ++++++++++++++--
  3790. + 1 file changed, 14 insertions(+), 2 deletions(-)
  3791. +
  3792. +--- a/drivers/thermal/sun8i_thermal.c
  3793. ++++ b/drivers/thermal/sun8i_thermal.c
  3794. +@@ -197,6 +197,9 @@ static irqreturn_t sun8i_irq_thread(int
  3795. + int i;
  3796. +
  3797. + for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) {
  3798. ++ /* We allow some zones to not register. */
  3799. ++ if (IS_ERR(tmdev->sensor[i].tzd))
  3800. ++ continue;
  3801. + thermal_zone_device_update(tmdev->sensor[i].tzd,
  3802. + THERMAL_EVENT_UNSPECIFIED);
  3803. + }
  3804. +@@ -531,8 +534,17 @@ static int sun8i_ths_register(struct ths
  3805. + i,
  3806. + &tmdev->sensor[i],
  3807. + &ths_ops);
  3808. +- if (IS_ERR(tmdev->sensor[i].tzd))
  3809. +- return PTR_ERR(tmdev->sensor[i].tzd);
  3810. ++
  3811. ++ /*
  3812. ++ * If an individual zone fails to register for reasons
  3813. ++ * other than probe deferral (eg, a bad DT) then carry
  3814. ++ * on, other zones might register successfully.
  3815. ++ */
  3816. ++ if (IS_ERR(tmdev->sensor[i].tzd)) {
  3817. ++ if (PTR_ERR(tmdev->sensor[i].tzd) == -EPROBE_DEFER)
  3818. ++ return PTR_ERR(tmdev->sensor[i].tzd);
  3819. ++ continue;
  3820. ++ }
  3821. +
  3822. + if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
  3823. + dev_warn(tmdev->dev,
  3824. diff --git a/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch b/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch
  3825. new file mode 100644
  3826. index 0000000000000..cd6542bf14419
  3827. --- /dev/null
  3828. +++ b/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch
  3829. @@ -0,0 +1,138 @@
  3830. +From f4318af40544b8e7ff5a6b667ede60e6cf808262 Mon Sep 17 00:00:00 2001
  3831. +From: Martin Botka <[email protected]>
  3832. +Date: Mon, 19 Feb 2024 15:36:39 +0000
  3833. +Subject: [PATCH] arm64: dts: allwinner: h616: Add thermal sensor and zones
  3834. +
  3835. +There are four thermal sensors:
  3836. +- CPU
  3837. +- GPU
  3838. +- VE
  3839. +- DRAM
  3840. +
  3841. +Add the thermal sensor configuration and the thermal zones.
  3842. +
  3843. +Signed-off-by: Martin Botka <[email protected]>
  3844. +Signed-off-by: Andre Przywara <[email protected]>
  3845. +Reviewed-by: Jernej Skrabec <[email protected]>
  3846. +Link: https://lore.kernel.org/r/[email protected]
  3847. +Signed-off-by: Jernej Skrabec <[email protected]>
  3848. +---
  3849. + .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 88 +++++++++++++++++++
  3850. + 1 file changed, 88 insertions(+)
  3851. +
  3852. +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
  3853. ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi
  3854. +@@ -9,6 +9,7 @@
  3855. + #include <dt-bindings/clock/sun6i-rtc.h>
  3856. + #include <dt-bindings/reset/sun50i-h616-ccu.h>
  3857. + #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
  3858. ++#include <dt-bindings/thermal/thermal.h>
  3859. +
  3860. + / {
  3861. + interrupt-parent = <&gic>;
  3862. +@@ -138,6 +139,10 @@
  3863. + reg = <0x03006000 0x1000>;
  3864. + #address-cells = <1>;
  3865. + #size-cells = <1>;
  3866. ++
  3867. ++ ths_calibration: thermal-sensor-calibration@14 {
  3868. ++ reg = <0x14 0x8>;
  3869. ++ };
  3870. + };
  3871. +
  3872. + watchdog: watchdog@30090a0 {
  3873. +@@ -511,6 +516,19 @@
  3874. + };
  3875. + };
  3876. +
  3877. ++ ths: thermal-sensor@5070400 {
  3878. ++ compatible = "allwinner,sun50i-h616-ths";
  3879. ++ reg = <0x05070400 0x400>;
  3880. ++ interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
  3881. ++ clocks = <&ccu CLK_BUS_THS>;
  3882. ++ clock-names = "bus";
  3883. ++ resets = <&ccu RST_BUS_THS>;
  3884. ++ nvmem-cells = <&ths_calibration>;
  3885. ++ nvmem-cell-names = "calibration";
  3886. ++ allwinner,sram = <&syscon>;
  3887. ++ #thermal-sensor-cells = <1>;
  3888. ++ };
  3889. ++
  3890. + usbotg: usb@5100000 {
  3891. + compatible = "allwinner,sun50i-h616-musb",
  3892. + "allwinner,sun8i-h3-musb";
  3893. +@@ -755,4 +773,74 @@
  3894. + #size-cells = <0>;
  3895. + };
  3896. + };
  3897. ++
  3898. ++ thermal-zones {
  3899. ++ cpu-thermal {
  3900. ++ polling-delay-passive = <500>;
  3901. ++ polling-delay = <1000>;
  3902. ++ thermal-sensors = <&ths 2>;
  3903. ++ sustainable-power = <1000>;
  3904. ++
  3905. ++ trips {
  3906. ++ cpu_threshold: cpu-trip-0 {
  3907. ++ temperature = <60000>;
  3908. ++ type = "passive";
  3909. ++ hysteresis = <0>;
  3910. ++ };
  3911. ++ cpu_target: cpu-trip-1 {
  3912. ++ temperature = <70000>;
  3913. ++ type = "passive";
  3914. ++ hysteresis = <0>;
  3915. ++ };
  3916. ++ cpu_critical: cpu-trip-2 {
  3917. ++ temperature = <110000>;
  3918. ++ type = "critical";
  3919. ++ hysteresis = <0>;
  3920. ++ };
  3921. ++ };
  3922. ++ };
  3923. ++
  3924. ++ gpu-thermal {
  3925. ++ polling-delay-passive = <500>;
  3926. ++ polling-delay = <1000>;
  3927. ++ thermal-sensors = <&ths 0>;
  3928. ++ sustainable-power = <1100>;
  3929. ++
  3930. ++ trips {
  3931. ++ gpu_temp_critical: gpu-trip-0 {
  3932. ++ temperature = <110000>;
  3933. ++ type = "critical";
  3934. ++ hysteresis = <0>;
  3935. ++ };
  3936. ++ };
  3937. ++ };
  3938. ++
  3939. ++ ve-thermal {
  3940. ++ polling-delay-passive = <0>;
  3941. ++ polling-delay = <0>;
  3942. ++ thermal-sensors = <&ths 1>;
  3943. ++
  3944. ++ trips {
  3945. ++ ve_temp_critical: ve-trip-0 {
  3946. ++ temperature = <110000>;
  3947. ++ type = "critical";
  3948. ++ hysteresis = <0>;
  3949. ++ };
  3950. ++ };
  3951. ++ };
  3952. ++
  3953. ++ ddr-thermal {
  3954. ++ polling-delay-passive = <0>;
  3955. ++ polling-delay = <0>;
  3956. ++ thermal-sensors = <&ths 3>;
  3957. ++
  3958. ++ trips {
  3959. ++ ddr_temp_critical: ddr-trip-0 {
  3960. ++ temperature = <110000>;
  3961. ++ type = "critical";
  3962. ++ hysteresis = <0>;
  3963. ++ };
  3964. ++ };
  3965. ++ };
  3966. ++ };
  3967. + };