Difference between revisions of "Bus services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 306: Line 306:
 
| [1.0.0-5.1.0] 3 || [[#HasDeviceForDev|HasDeviceForDev]]
 
| [1.0.0-5.1.0] 3 || [[#HasDeviceForDev|HasDeviceForDev]]
 
|-
 
|-
| 4 || [6.0.0+]
+
| 4 || [6.0.0+] [[#OpenSessionWithId|OpenSessionWithId]]
 
|}
 
|}
  
Line 390: Line 390:
 
== HasDeviceForDev ==
 
== HasDeviceForDev ==
 
Takes an u32 '''port''', an u16 '''addr''', an '''AddressingMode''' (1 for 10-bit, 0 otherwise) and a '''SpeedMode''' (400000 or 100000). Returns true if the device exists or false otherwise.
 
Takes an u32 '''port''', an u16 '''addr''', an '''AddressingMode''' (1 for 10-bit, 0 otherwise) and a '''SpeedMode''' (400000 or 100000). Returns true if the device exists or false otherwise.
 +
 +
== OpenSessionWithId ==
 +
Takes an '''I2cId''' and returns a [[#II2cSession]] session for it.
  
 
== II2cSession ==
 
== II2cSession ==
Line 414: Line 417:
  
 
== SendAuto ==
 
== SendAuto ==
 
 
Takes bytes to write in either a static buffer or a receive buffer, returns an error code for success
 
Takes bytes to write in either a static buffer or a receive buffer, returns an error code for success
  
 
== ExecuteCommandListAuto ==
 
== ExecuteCommandListAuto ==
 
 
Takes a command list from either a static buffer or a receive buffer, returns data in either a static (or recieve?) buffer.
 
Takes a command list from either a static buffer or a receive buffer, returns data in either a static (or recieve?) buffer.
  
 
=== Commands ===
 
=== Commands ===
 
 
* 0x40 [u8 len] <bytes> - Write bytes to device
 
* 0x40 [u8 len] <bytes> - Write bytes to device
 
* 0xC1 [u8 len] - Receive bytes from device
 
* 0xC1 [u8 len] - Receive bytes from device

Revision as of 19:43, 4 May 2019

gpio

This is "nn::gpio::IManager".

Cmd Name
0 #OpenSessionForDev
1 #OpenSession
2 #OpenSessionForTest
3 [1.0.0-6.2.0] IsWakeEventActive
4 [1.0.0-6.2.0] GetWakeEventActiveFlagSet
5 [1.0.0-6.2.0] SetWakeEventActiveFlagSetForDebug
6 SetWakePinDebugMode
7 [5.0.0+] #OpenSession2
8 [5.0.0+] IsWakeEventActive2
9 [5.0.0+] SetWakeEventActiveFlagSetForDebug2
10 [6.0.0+]

Known Devices

GpioPadName GpioPadDescriptor Tegra (port, pin) Usage Direction Used by
0x01 0xCC Z, 4 Audio Codec (ALC5639) Power Out Icosa, Hoag, [5.0.0+] Mariko
(Audio services, Fatal services)
0x02 0x24 E, 4 SDCard Power Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(Filesystem services)
0x03 0x3C H, 4 BT_RST_PH4 Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(Bluetooth Driver services)
0x04 0xDA BB, 2 In Icosa, Hoag, [5.0.0+] Mariko
0x05 0xDB BB, 3 GcAsic Power Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(Filesystem services)
0x06 0xDC BB, 4 Headphone Detect In Icosa, Hoag, [5.0.0+] Mariko
(Audio services)
0x07 0x25 E, 5 Out Icosa, Copper, Hoag
0x08 0x90 S, 0 DebugPadDriver In Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x09 0x91 S, 1 In Icosa, Hoag, [5.0.0+] Mariko
0x0A 0x96 S, 6 Charger IC (BQ24193) Charge Enable Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services)
0x0B 0x97 S, 7 CPU fan sampling In Icosa, Hoag, [5.0.0+] Mariko
0x0C 0x26 E, 6 Joy-Con(L) IsAttached (insertion, Joy-Con pin 5/console TX, pulled low on insert?) In Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x0D 0x05 A, 5 Fan enable (normal) Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services)
0x0E 0x78 P, 0 SDMMC3_CLK_PP0? In Icosa, Hoag, [5.0.0+] Mariko
0x0F 0x93 S, 3 GcAsic IRQ In Icosa, Copper, Hoag, [5.0.0+] Mariko
(Filesystem services)
0x10 0x7D P, 5 SDMMC3_DAT0_PP5? In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x11 0x7C P, 4 SDMMC3_DAT1_PP4? In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x12 0x7B P, 3 SDMMC3_DAT2_PP3? In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x13 0x7A P, 2 SDMMC3_DAT3_PP2? In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x14 0xBC X, 4 Temperature Sensor In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x15 0xAE V, 6 In Icosa, Hoag, [5.0.0+] Mariko
(Audio services)
0x16 0xBA X, 2 MOTION_INT_PX2? In Icosa, Hoag, [5.0.0+] Mariko
0x17 0xB9 X, 1 TouchPanel IRQ (TOUCH_INT_PX1) (unused - polled instead) In Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x18 0xBD X, 5 Power Button (BUTTON_POWER_ON_PX5) In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x19 0xBE X, 6 Volume Up (BUTTON_VOL_UP_PX6) In Icosa, Copper, Hoag, [5.0.0+] Mariko
(Boot2, Audio services)
0x1A 0xBF X, 7 Volume Down (BUTTON_VOL_DOWN_PX7) In Icosa, Copper, Hoag, [5.0.0+] Mariko
(Boot2, Audio services)
0x1B 0xC0 Y, 0 Fuel Gauge IC (MAX17050) IRQ In Icosa, Hoag, [5.0.0+] Mariko
(PTM services)
0x1C 0xC1 Y, 1 BUTTON_HOME_PY1 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x1D 0xA9 V, 1 Backlight Enable (LCD_BL_EN_PV1) Out Icosa, Hoag, [5.0.0+] Mariko
(NV services, Backlight services)
0x1E 0xAA V, 2 Backlight Reset (LCD_RST_PV2) Out Icosa, Hoag, [5.0.0+] Mariko
(NV services)
0x1F 0x55 K, 5 Charger IC (BQ24193) OTG charge select Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services, USB services)
0x20 0xAD V, 5 USB-PD controller (RHOM BM92T30MWV) related Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(USB services)
0x21 0xC8 Z, 0 Charger IC (BQ24193) IRQ In Icosa, Hoag, [5.0.0+] Mariko
(PTM services)
0x22 0xCA Z, 2 In Icosa, Hoag, [5.0.0+] Mariko
0x23 0xCB Z, 3 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x24 0x4F J, 7 TouchPanel reset Out Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x25 0x50 K, 0 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x26 0x51 K, 1 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x27 0x52 K, 2 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x28 0x54 K, 4 USB-PD controller (RHOM BM92T30MWV) IRQ In Icosa, Copper, Hoag, [5.0.0+] Mariko
(USB services)
0x29 0x56 K, 6 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x2A 0x57 K, 7 In Icosa, Copper, Hoag
0x2B 0x53 K, 3 Joy-Con(R) NwcpDriver1.NwcpCharger Out Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x2C 0xE3 CC, 3 Joy-Con(L) NwcpDriver0.NwcpCharger Out Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x2D 0x38 H, 0 WIFI_EN_PH0? Out Icosa, Copper, Hoag, [5.0.0+] Mariko
0x2E 0x39 H, 1 WIFI_RST_PH1 Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(Wlan services, PCIe services)
0x2F 0x3B H, 3 AP_WAKE_BT_PH3 Out Icosa, Copper, Hoag, [5.0.0+] Mariko
(Bluetooth Driver services)
0x30 0x3D H, 5 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x31 0x3F H, 7 Out Icosa, Copper, Hoag, [5.0.0+] Mariko
0x32 0x40 I, 0 Backlight +5V Out Icosa, Hoag, [5.0.0+] Mariko
(NV services)
0x33 0x41 I, 1 Backlight -5V Out Icosa, Hoag, [5.0.0+] Mariko
(NV services)
0x34 0x3E H, 6 Joy-Con(R) IsAttached (insertion, Joy-Con pin 5/console TX, pulled low on insert?) In Icosa, Hoag, [5.0.0+] Mariko
(HID services)
0x35 0xE2 CC, 2 In Icosa, Hoag, [5.0.0+] Mariko
0x36 0xE4 CC, 4 Fan enable (high power) Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services)
0x37 0x3A H, 2 In Icosa, Copper, Hoag, [5.0.0+] Mariko
0x38 0xC9 Z, 1 SDCard Card Detect In Icosa, Copper, Hoag, [5.0.0+] Mariko
(Filesystem services)
0x39 0x4D J, 5 Charger IC (BQ24193) OTG charge select Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services, USB services)
0x3A 0x58 L, 0 Charger IC (BQ24193) OTG charge select Out Icosa, Hoag, [5.0.0+] Mariko
(PTM services, USB services)
0x3B 0x3E H, 6 Joy-Con(R) NwcpDriver1.GpioMonitorTask0 duplicate? In Icosa, Hoag, [5.0.0+] Mariko
0x3C 0x26 E, 6 Joy-Con(L) NwcpDriver1.GpioMonitorTask0 duplicate? In Icosa, Hoag, [5.0.0+] Mariko
0x3D -1
0x3E 0x33 G, 3 Joy-Con(R) CTS (checked low) In None
(HID services)
0x3F 0x1C D, 4 Joy-Con(L) CTS (checked low) In None
(HID services)
0x40 0xD9 BB, 1 Out [2.0.0+] Copper
0x41 0x0C B, 4 Lid Closed (unused) In [2.0.0+] Copper
0x42 0x0D B, 5 In [2.0.0+] Copper
0x43 0x21 E, 1 USB power Out [2.0.0+] Copper
(USB services)
0x44 0x27 E, 7 In [2.0.0+] Copper
0x45 0x92 S, 2 In [2.0.0+] Copper
0x46 0x95 S, 5 USB root port 4 power Out [2.0.0+] Copper
(USB services)
0x47 0x98 T, 0 USB root port 3 power Out [2.0.0+] Copper
(USB services)
0x48 0x10 C, 0 HdmiHotplug Out [2.0.0+] Copper
(NV services)
0x49 0x11 C, 1 USB root port 2 power Out [2.0.0+] Copper
(USB services)
0x4A 0x12 C, 2 HdmiHotplug Out [2.0.0+] Copper
(NV services)
0x4B 0x42 I, 2 Out [2.0.0+] Copper
0x4C 0xE6 CC, 6 In [2.0.0+] Copper
[2.0.0+] 0x4D 0xAC V, 4 Out [2.0.0+] Copper
[2.0.0+] 0x4E 0xE1 CC, 1 HdmiHotplug (HDMI_INT_DP_HPD_PCC1) In [2.0.0+] Copper
(NV services)
[5.0.0+] 0x4F 0x56 K, 6 None
[6.0.0+] 0x50 0x20 E, 0 None
[6.0.0+] 0x51 0x21 E, 1 None
[6.0.0+] 0x52 0x22 E, 2 None
[6.0.0+] 0x53 0x23 E, 3 None
[6.0.0+] 0x54 0x4C J, 4 None
[6.0.0+] 0x55 0x57 K, 7 None
[6.0.0+] 0x56 0x94 S, 4 None
[6.0.0+] 0x57 0x98 T, 0 None
[6.0.0+] 0x58 0x99 T, 1 None
[6.0.0+] 0x59 0xBB X, 3 None
[6.0.0+] 0x5A 0xE5 CC, 5 None
[6.0.0+] 0x5B 0xAB V, 3 None
[6.0.0+] 0x5C 0x4E J, 6 None
- 0x32 G, 2 Joy-Con(R) RTS None
- 0x1B D, 3 Joy-Con(L) RTS None

GpioPadDescriptor

Bits Description
7-5 Controller index
4-3 Port index
2-0 Pin number

OpenSessionForDev

Takes a raw #GpioPadDescriptor and returns a #IPadSession session for it.

OpenSession

Same thing as #OpenSessionForDev except it takes a GpioPadName which is then converted to a #GpioPadDescriptor. Returns an #IPadSession session.

OpenSessionForTest

Same as #OpenSession but panics on failure.

OpenSession2

Same as #OpenSession but takes a DeviceCode instead of a GpioPadName.

IPadSession

This is "nn::gpio::IPadSession".

Cmd Name
0 SetDirection
1 GetDirection
2 SetInterruptMode
3 GetInterruptMode
4 SetInterruptEnable
5 GetInterruptEnable
6 GetInterruptStatus
7 ClearInterruptStatus
8 SetValue
9 GetValue
10 BindInterrupt
11 UnbindInterrupt
12 SetDebounceEnabled
13 GetDebounceEnabled
14 SetDebounceTime
15 GetDebounceTime
16 [4.0.0+] SetValueForSleepState
17 [6.0.0+]

i2c, i2c:pcv

This is "nn::i2c::IManager".

Cmd Name
0 OpenSessionForDev
1 OpenSession
[1.0.0-5.1.0] 2 HasDevice
[1.0.0-5.1.0] 3 HasDeviceForDev
4 [6.0.0+] OpenSessionWithId

Known Devices

Name ID Port:Addr Is10bit Speed Max Retries Retry Delay Usage Used by
0 0x350000C9 0:52 N 100000 0 0 DebugPadDriver HID services
1 0x35000033 2:49 N 400000 0 0 TouchPanel HID services
2 0x3E000001 0:4c N 100000 0 0 Temperature Sensor (TMP451 or NCT72) PTM services
3 0x3E000001 0:4c N 100000 0 0 Temperature Sensor (TMP451 or NCT72) (duplicate)
4 0x33000001 0:1c N 100000 0 0 Audio Codec (ALC5639) Audio services, Fatal services
5 0x3B000001 4:68 N 400000 3 5000000 PMIC RTC (max77620_rtc0), max77620_irq0 PCV services
6 0x3A000001 4:3c N 400000 3 5000000 PMIC (MAX77620), max77620_irq0 PCV services
7 0x3A000003 4:1b N 400000 3 5000000 Sub-PMIC for CPU (max77621_cpu) PCV services
8 0x3A000004 4:1c N 400000 3 5000000 Sub-PMIC for GPU (max77621_gpu) PCV services
9 0x39000001 0:6b N 100000 3 5000000 Charger IC (BQ24193) PTM services
10 0x39000033 0:36 N 100000 3 5000000 Fuel Gauge IC (MAX17050) PCV services, PTM services
11 0x040000C9 0:18 N 100000 3 5000000 USB-PD controller (RHOM BM92T30MWV) USB services
12 0x3F000401 1:40 N 400000 3 5000000 Power Monitor (ina226_V_VDD15V0-HB) Factory testing
13 0x3F000001 1:41 N 400000 3 5000000 Power Monitor (ina226_V_VSYS-CPU-DS) Factory testing
14 0x3F000002 1:44 N 400000 3 5000000 Power Monitor (ina226_V_VSYS-GPU-DS) Factory testing
15 0x3F000003 1:45 N 400000 3 5000000 Power Monitor (ina226_V_VSYS-DDR-DS) Factory testing
16 0x3F000402 1:46 N 400000 3 5000000 Power Monitor (ina226_V_VSYS-AP) Factory testing
17 0x3F000403 1:47 N 400000 3 5000000 Power Monitor (ina226_V_VSYS-BL-DS) Factory testing
18 0x35000047 1:29 N 400000 3 5000000 Ambient Light Sensor (BH1730) Backlight services
19 0x3F000404 1:48 N 400000 3 5000000 Power Monitor (ina226_CORE) Factory testing
20 0x3F000405 1:49 N 400000 3 5000000 Power Monitor (ina226_Soc-1V8) Factory testing
21 0x3F000406 1:4a N 400000 3 5000000 Power Monitor (ina226_LPDDR4-1V8) Factory testing
22 0x3F000407 1:4b N 400000 3 5000000 Power Monitor (ina226_REG1V32) Factory testing
23 0x3F000408 1:4d N 400000 3 5000000 Power Monitor (ina226_VDD3V3-SYS) Factory testing
[2.0.0+] 24 0x34000001 3:50 N 100000 0 0 HDMI DDC NV services
[2.0.0+] 25 0x34000002 3:54 N 100000 0 0 HDMI SCDC NV services
[2.0.0+] 26 0x34000003 3:3a N 100000 0 0 HDMI HDCP NV services
[4.0.0+] 27 0x3A000005 4:a4 N 400000 0 0 Fan (Fan53528)
[4.0.0+] 28 0x3A000002 4:31 N 400000 0 0 PMIC (Max77812)
[4.0.0+] 29 0x3A000002 4:33 N 400000 0 0 PMIC (Max77812)
[4.0.0+] 30 0x3F000409 1:4e N 400000 3 5000000 Power Monitor (ina226_V_VDD-DDR-0V6)
[8.0.0+] 31 0x36000001 1:08 N 400000 3 5000000

OpenSessionForDev

Takes an u32 port, an u16 addr, an AddressingMode (1 for 10-bit, 0 otherwise) and a SpeedMode (400000 or 100000). Returns a #II2cSession session.

OpenSession

Takes an I2cDevice and returns a #II2cSession session for it.

HasDevice

Takes an I2cDevice and returns true if the device exists or false otherwise.

HasDeviceForDev

Takes an u32 port, an u16 addr, an AddressingMode (1 for 10-bit, 0 otherwise) and a SpeedMode (400000 or 100000). Returns true if the device exists or false otherwise.

OpenSessionWithId

Takes an I2cId and returns a #II2cSession session for it.

II2cSession

This is "nn::i2c::ISession".

Cmd Name
[1.0.0-5.1.0] 0 Send
[1.0.0-5.1.0] 1 Receive
[1.0.0-5.1.0] 2 ExecuteCommandList
10 #SendAuto
11 ReceiveAuto
12 #ExecuteCommandListAuto
13 [6.0.0+]

SendAuto

Takes bytes to write in either a static buffer or a receive buffer, returns an error code for success

ExecuteCommandListAuto

Takes a command list from either a static buffer or a receive buffer, returns data in either a static (or recieve?) buffer.

Commands

  • 0x40 [u8 len] <bytes> - Write bytes to device
  • 0xC1 [u8 len] - Receive bytes from device

uart

This is "nn::uart::IManager".

Cmd Name
0 #DoesUartExist
1 DoesUartExistForTest
2 #IsUartBaudrateValid
3 IsUartBaudrateValidForTest
4 #IsSomethingUartValid
5 IsSomethingUartValidForTest
6 #GetSession
7 IsSomethingUartValid2
8 IsSomethingUartValid2ForTest
9 [7.0.0+] IsSomethingUartValid3
10 [7.0.0+] IsSomethingUartValid3ForTest

DoesUartExist

Takes a u32 #UartPort and returns boolean success value

IsUartBaudrateValid

Takes a u32 #UartPort and a u32 baudrate and returns boolean success value

IsSomethingUartValid

Takes a u32 #UartPort and returns boolean success value

GetSession

Takes a u32 #UartPort and returns an #IPortSession

UartPort

Name Port Usage
1 UART-D Bluetooth
2 UART-B Joy-Con(R)
3 UART-C Joy-Con(L)

IPortSession

This is "nn::uart::IPortSession".

Cmd Name
0 OpenSession
1 OpenSessionForTest
2
3
4
5
6
7

[7.0.0+] OpenSession/OpenSessionForTest now takes an additional 0x8-bytes of input.

Port Mapping

OpenSession translates user IDs to to the #UartPort index.

OpenSessionForTest takes the port index verbatim.

pwm

This is "nn::pwm::IManager".

Cmd Name
0 OpenSessionForDev
1 OpenSession
2 [6.0.0+]

Known Channels

Name Interface Usage Used by
1 PWM Channel 1 Fan PTM services
2 PWM Channel 0 Backlight Backlight services, NV services
3 PMC Blinker

IChannelSession

This is "nn::pwm::IChannelSession".

Cmd Name
0 SetPeriod
1 GetPeriod
2 SetDuty
3 GetDuty
4 SetEnabled
5 GetEnabled
6 [6.0.0+]
7 [6.0.0+]

pinmux

This is "nn::pinmux::IManager".

Cmd Name
0 OpenSession

ISession

This is "nn::pinmux::ISession".

Cmd Name
0 SetPinAssignment
1 GetPinAssignment
2 SetPinAssignmentForHardwareTest

sasbus

This is "nn::sasbus::IManager".

Cmd Name
0 OpenSession

ISession

This is "nn::sasbus::ISession".

Cmd Name
0
1
2
3