From 948a925bf5b4ed698c25381c85f00c58b82e3930 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Tue, 5 Jun 2012 01:28:46 +0200 Subject: [PATCH] nfc --- galaxys3_base.mk | 47 ++++++++++++--- nfc/Android.mk | 25 ++++++++ nfc/nfc_hw.c | 134 +++++++++++++++++++++++++++++++++++++++++ nfcee_access.xml | 11 ++++ nfcee_access_debug.xml | 17 ++++++ 5 files changed, 225 insertions(+), 9 deletions(-) create mode 100644 nfc/Android.mk create mode 100644 nfc/nfc_hw.c create mode 100644 nfcee_access.xml create mode 100644 nfcee_access_debug.xml diff --git a/galaxys3_base.mk b/galaxys3_base.mk index d3c053e2..11f900e4 100644 --- a/galaxys3_base.mk +++ b/galaxys3_base.mk @@ -78,15 +78,43 @@ PRODUCT_PACKAGES += \ libhwconverter \ libhwjpeg \ libfimg \ - libtinyalsa - #libhdmi \ - #libfimc \ - #libhwcomposer \ - #libcec \ - #libddc \ - #libedid \ - #libhdmiclient \ - #libTVOut \ + libtinyalsa \ + nfc.exynos4 + +#libhdmi \ +#libfimc \ +#libhwcomposer \ +#libcec \ +#libddc \ +#libedid \ +#libhdmiclient \ +#libTVOut \ + +# NFC +PRODUCT_PACKAGES += \ + libnfc \ + libnfc_jni \ + Nfc \ + Tag + +PRODUCT_COPY_FILES += \ + packages/apps/Nfc/migrate_nfc.txt:system/etc/updatecmds/migrate_nfc.txt \ + device/sample/nxp/com.nxp.mifare.xml:system/etc/permissions/com.nxp.mifare.xml \ + frameworks/base/nfc-extras/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml \ + frameworks/base/data/etc/android.hardware.nfc.xml:system/etc/permissions/android.hardware.nfc.xml + +# NFCEE access control +ifeq ($(TARGET_BUILD_VARIANT),user) + NFCEE_ACCESS_PATH := device/samsung/i9300/nfcee_access.xml +else + NFCEE_ACCESS_PATH := device/samsung/i9300/nfcee_access_debug.xml +endif + +PRODUCT_COPY_FILES += \ + $(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml + +PRODUCT_PACKAGES += \ + com.android.nfc_extras # MFC API PRODUCT_PACKAGES += \ @@ -183,3 +211,4 @@ $(call inherit-product, frameworks/base/build/phone-xhdpi-1024-dalvik-heap.mk) TARGET_HAL_PATH := hardware/samsung/exynos4/hal TARGET_OMX_PATH := hardware/samsung/exynos/multimedia/openmax $(call inherit-product, hardware/samsung/exynos4x12.mk) +$(call inherit-product, vendor/cm/config/nfc_enhanced.mk) diff --git a/nfc/Android.mk b/nfc/Android.mk new file mode 100644 index 00000000..1b82fa3f --- /dev/null +++ b/nfc/Android.mk @@ -0,0 +1,25 @@ +# Copyright (C) 2011 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := nfc.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw +LOCAL_SRC_FILES := nfc_hw.c +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/nfc/nfc_hw.c b/nfc/nfc_hw.c new file mode 100644 index 00000000..b604768f --- /dev/null +++ b/nfc/nfc_hw.c @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include +#include + +static uint8_t pn544_eedata_settings[][4] = { + // DIFFERENTIAL_ANTENNA + + // RF Settings + {0x00,0x9B,0xD1,0x0D} // Tx consumption higher than 0x0D (average 50mA) + ,{0x00,0x9B,0xD2,0x24} // GSP setting for this threshold + ,{0x00,0x9B,0xD3,0x0A} // Tx consumption higher than 0x0A (average 40mA) + ,{0x00,0x9B,0xD4,0x22} // GSP setting for this threshold + ,{0x00,0x9B,0xD5,0x08} // Tx consumption higher than 0x08 (average 30mA) + ,{0x00,0x9B,0xD6,0x1E} // GSP setting for this threshold + ,{0x00,0x9B,0xDD,0x1C} // GSP setting for this threshold + ,{0x00,0x9B,0x84,0x13} // ANACM2 setting + ,{0x00,0x99,0x81,0x7F} // ANAVMID setting PCD + ,{0x00,0x99,0x31,0x70} // ANAVMID setting PICC + + // Enable PBTF + ,{0x00,0x98,0x00,0x3F} // SECURE_ELEMENT_CONFIGURATION - No Secure Element + ,{0x00,0x9F,0x09,0x00} // SWP_PBTF_RFU + ,{0x00,0x9F,0x0A,0x05} // SWP_PBTF_RFLD --> RFLEVEL Detector for PBTF + ,{0x00,0x9E,0xD1,0xA1} // + + // Change RF Level Detector ANARFLDWU + ,{0x00,0x99,0x23,0x00} // Default Value is 0x01 + + // Low-power polling + ,{0x00,0x9E,0x74,0xB0} // Default Value is 0x00, bits 0->2: sensitivity (0==max, 6==min), + // bit 3: RFU, + // bits 4,5 hybrid low-power: # of low-power polls per regular poll + // bit 6: RFU + // bit 7: (0 -> disabled, 1 -> enabled) + ,{0x00,0x9E,0x7D,0xB0} // bits 0->3: RFU, + // bits 4,5: # retries after low power detection + // 0=1 retry, 1=2 retry, 2=3 retry, 3=4 retry + // bit 6: RFU, + // bit 7: Enable or disable retry mechanism (0: disable, 1: enable) + ,{0x00,0x9F,0x28,0x01} // bits 0->7: # of measurements per low-power poll + + //LLC Timer + ,{0x00,0x9C,0x31,0x00} // Guard host time-out in ms (MSB) + ,{0x00,0x9C,0x32,0xC8} // Guard host time-out in ms (LSB) + ,{0x00,0x9C,0x19,0x40} // Max RX retry (PN544=>host?) + ,{0x00,0x9C,0x1A,0x40} // Max TX retry (PN544=>host?) + + ,{0x00,0x9C,0x0C,0x00} // + ,{0x00,0x9C,0x0D,0x00} // + ,{0x00,0x9C,0x12,0x00} // + ,{0x00,0x9C,0x13,0x00} // + + //WTX for LLCP communication + ,{0x00,0x98,0xA2,0x0E} // Max value: 14 (default value: 09) + + //SE GPIO + ,{0x00, 0x98, 0x93, 0x40} + + // Set NFCT ATQA + ,{0x00, 0x98, 0x7D, 0x02} + ,{0x00, 0x98, 0x7E, 0x00} + + // Enable CEA detection mechanism + ,{0x00, 0x9F, 0xC8, 0x01} + // Set NFC-F poll RC=0x00 + ,{0x00, 0x9F, 0x9A, 0x00} + // Setting for EMD support for ISO 14443-4 Reader + ,{0x00,0x9F,0x09,0x00} // 0x00 - Disable EMD support, 0x01 - Enable EMD support +}; + +static int pn544_close(hw_device_t *dev) { + free(dev); + + return 0; +} + +/* + * Generic device handling + */ + +static int nfc_open(const hw_module_t* module, const char* name, + hw_device_t** device) { + if (strcmp(name, NFC_PN544_CONTROLLER) == 0) { + nfc_pn544_device_t *dev = calloc(1, sizeof(nfc_pn544_device_t)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*) module; + dev->common.close = pn544_close; + + dev->num_eeprom_settings = sizeof(pn544_eedata_settings) / 4; + dev->eeprom_settings = (uint8_t*)pn544_eedata_settings; + dev->linktype = PN544_LINK_TYPE_I2C; + dev->device_node = "/dev/pn544"; + dev->enable_i2c_workaround = 1; + *device = (hw_device_t*) dev; + return 0; + } else { + return -EINVAL; + } +} + +static struct hw_module_methods_t nfc_module_methods = { + .open = nfc_open, +}; + +struct nfc_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = NFC_HARDWARE_MODULE_ID, + .name = "Herring NFC HW HAL", + .author = "The Android Open Source Project", + .methods = &nfc_module_methods, + }, +}; diff --git a/nfcee_access.xml b/nfcee_access.xml new file mode 100644 index 00000000..02e12fd9 --- /dev/null +++ b/nfcee_access.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/nfcee_access_debug.xml b/nfcee_access_debug.xml new file mode 100644 index 00000000..a96a2d1d --- /dev/null +++ b/nfcee_access_debug.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + +