Skip to content

Commit 03ba6e2

Browse files
committed
soc: apple: aop: Add support for aop on t602x
Aop requires a different "EC0p" bootarg value of 0x0100_00000000. Use the driver's IdInfo to specify this for "apple,aop-t6020". Since this matches "vm-base" from the ADT set the dma (coherent) mask to dma_bit_mask(42) to work with set "apple,dma-range" in aop_dart. "apple,aop-t6020" uses more endpoint so bump AFK_ENDPOINT_COUNT to 0xf. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 4ae6d88 commit 03ba6e2

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

drivers/soc/apple/aop.rs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::{arch::asm, mem, ptr, slice};
1010
use kernel::{
1111
bindings, c_str,
1212
devres::Devres,
13-
dma::CoherentAllocation,
13+
dma::{dma_bit_mask, CoherentAllocation, Device},
1414
error::from_err_ptr,
1515
io::mem::IoMem,
1616
module_platform_driver, new_condvar, new_mutex, of, platform,
@@ -29,7 +29,7 @@ const BOOTARGS_SIZE: usize = 0x230;
2929
const CPU_CONTROL: usize = 0x44;
3030
const CPU_RUN: u32 = 0x1 << 4;
3131
const AFK_ENDPOINT_START: u8 = 0x20;
32-
const AFK_ENDPOINT_COUNT: u8 = 0xc;
32+
const AFK_ENDPOINT_COUNT: u8 = 0xf;
3333
const AFK_OPC_GET_BUF: u64 = 0x89;
3434
const AFK_OPC_INIT: u64 = 0x80;
3535
const AFK_OPC_INIT_RX: u64 = 0x8b;
@@ -746,7 +746,7 @@ impl AopData {
746746
}
747747
}
748748

749-
fn patch_bootargs(&self, patches: &[(u32, u32)]) -> Result<()> {
749+
fn patch_bootargs(&self, patches: &[(u32, u64)]) -> Result<()> {
750750
let offset = self.aop_read32(BOOTARGS_OFFSET) as usize;
751751
let size = self.aop_read32(BOOTARGS_SIZE) as usize;
752752
let mut arg_bytes = KVec::with_capacity(size, GFP_KERNEL)?;
@@ -864,28 +864,45 @@ impl rtkit::Operations for AopData {
864864
#[repr(transparent)]
865865
struct AopDriver(Arc<dyn AOP>);
866866

867+
struct AopHwConfig {
868+
ec0p: u64,
869+
}
870+
871+
const HW_CFG_T6020: AopHwConfig = AopHwConfig {
872+
ec0p: 0x0100_00000000,
873+
};
874+
const HW_CFG_DEFAULT: AopHwConfig = AopHwConfig { ec0p: 0x020000 };
875+
867876
kernel::of_device_table!(
868877
OF_TABLE,
869878
MODULE_OF_TABLE,
870-
(),
871-
[(of::DeviceId::new(c_str!("apple,aop")), ())]
879+
<AopDriver as platform::Driver>::IdInfo,
880+
[
881+
(of::DeviceId::new(c_str!("apple,aop-t6020")), &HW_CFG_T6020),
882+
(of::DeviceId::new(c_str!("apple,aop")), &HW_CFG_DEFAULT)
883+
]
872884
);
873885

874886
impl platform::Driver for AopDriver {
875-
type IdInfo = ();
887+
type IdInfo = &'static AopHwConfig;
876888

877-
const OF_ID_TABLE: Option<of::IdTable<()>> = Some(&OF_TABLE);
889+
const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
878890

879-
fn probe(pdev: &mut platform::Device, _info: Option<&()>) -> Result<Pin<KBox<AopDriver>>> {
891+
fn probe(
892+
pdev: &mut platform::Device,
893+
info: Option<&Self::IdInfo>,
894+
) -> Result<Pin<KBox<AopDriver>>> {
895+
let cfg = info.ok_or(ENODEV)?;
896+
pdev.dma_set_mask_and_coherent(dma_bit_mask(42))?;
880897
let data = AopData::new(pdev)?;
881898
let of = pdev.as_ref().of_node().ok_or(EIO)?;
882-
let alig = of.get_property(c_str!("apple,aop-alignment"))?;
883-
let aopt = of.get_property(c_str!("apple,aop-target"))?;
899+
let alig = of.get_property::<u32>(c_str!("apple,aop-alignment"))?;
900+
let aopt = of.get_property::<u32>(c_str!("apple,aop-target"))?;
884901
data.patch_bootargs(&[
885-
(from_fourcc(b"EC0p"), 0x20000),
902+
(from_fourcc(b"EC0p"), cfg.ec0p),
886903
(from_fourcc(b"nCal"), 0x0),
887-
(from_fourcc(b"alig"), alig),
888-
(from_fourcc(b"AOPt"), aopt),
904+
(from_fourcc(b"alig"), alig.into()),
905+
(from_fourcc(b"AOPt"), aopt.into()),
889906
])?;
890907
let rtkit = rtkit::RtKit::<AopData>::new(pdev.as_ref(), None, 0, data.clone())?;
891908
*data.rtkit.lock() = Some(rtkit);

0 commit comments

Comments
 (0)