first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2015 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
LIBLM3534_DIR := $(GET_LOCAL_DIR)
|
||||
LIBLM3534_BUILD := $(call TOLIBDIR,$(LIBLM3534_DIR)/LIBLM3534.a)
|
||||
COMMONLIBS += LIBLM3534
|
||||
|
||||
# Only process the remainder of the makefile if we are building libraries
|
||||
#
|
||||
ifeq ($(MAKEPHASE),libraries)
|
||||
|
||||
LIBLM3534_OBJS := $(LIBLM3534_DIR)/lm3534.o
|
||||
|
||||
LIBLM3534_OBJS := $(call TOLIBOBJDIR,$(LIBLM3534_OBJS))
|
||||
|
||||
ALL_DEPS += $(LIBLM3534_OBJS:%o=%d)
|
||||
|
||||
$(LIBLM3534_BUILD): $(LIBLM3534_OBJS)
|
||||
|
||||
endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
#include <debug.h>
|
||||
#include <drivers/iic.h>
|
||||
#include <lib/mib.h>
|
||||
#include <sys.h>
|
||||
#include <target.h>
|
||||
|
||||
#define LM3534_GPR (0x10)
|
||||
#define LM3534_DFS (0x11)
|
||||
#define LM3534_RRR (0x12)
|
||||
#define LM3534_BRL (0x13)
|
||||
#define LM3534_BRH (0x14)
|
||||
#define LM3534_AFT (0x32)
|
||||
|
||||
static bool lm3534_probed;
|
||||
static uint32_t lm3534_address[2];
|
||||
static uint32_t lm3534_bus[2];
|
||||
static bool lm3534_present[2];
|
||||
|
||||
int lm3534_backlight_probe(void)
|
||||
{
|
||||
uint8_t data[1];
|
||||
|
||||
if (lm3534_probed)
|
||||
return lm3534_present[0] ? 0 : -1;
|
||||
lm3534_probed = true;
|
||||
|
||||
lm3534_bus[0] = mib_get_u32(kMIBTargetBacklight0I2CBus);
|
||||
lm3534_bus[1] = mib_get_u32_opt(kMIBTargetBacklight1I2CBus, (uint32_t)-1);
|
||||
lm3534_address[0] = mib_get_u32(kMIBTargetBacklight0I2CAddress);
|
||||
lm3534_address[1] = mib_get_u32_opt(kMIBTargetBacklight1I2CAddress, (uint32_t)-1);
|
||||
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if (lm3534_bus[i] == (uint32_t)-1) {
|
||||
break;
|
||||
}
|
||||
|
||||
dprintf(DEBUG_SPEW, "lm3534: probing backlight controller %u at i2c%u address 0x%x\n", i, lm3534_bus[i], lm3534_address[i]);
|
||||
|
||||
// Probe for the LM3534 by reading a register
|
||||
data[0] = LM3534_GPR;
|
||||
if (iic_read(lm3534_bus[i], lm3534_address[i], data, 1, data, 1, IIC_NORMAL) == 0) {
|
||||
// Mark the LM3534 as present
|
||||
lm3534_present[i] = true;
|
||||
}
|
||||
|
||||
if (!lm3534_present[i]) {
|
||||
if (i == 0) {
|
||||
// Return an error if the first LM3534 is not present
|
||||
dprintf(DEBUG_INFO, "lm3534: failed to detect backlight controller, bailing\n");
|
||||
return -1;
|
||||
} else {
|
||||
// Depending on the display card attached, the second backlight
|
||||
// controller may or may not exist. Its absense is not fatal.
|
||||
dprintf(DEBUG_INFO, "lm3534: failed to detect second backlight controller, ignoring\n");
|
||||
}
|
||||
} else {
|
||||
dprintf(DEBUG_SPEW, "lm3534: successfully probed backlight controller %u with value 0x%x\n", i, data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lm3534_backlight_enable(uint32_t backlight_level)
|
||||
{
|
||||
uint8_t data[2];
|
||||
|
||||
if (!lm3534_probed) {
|
||||
lm3534_backlight_probe();
|
||||
}
|
||||
|
||||
if (!lm3534_present[0])
|
||||
return -1;
|
||||
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if (!lm3534_present[i])
|
||||
break;
|
||||
|
||||
// Configure the backlight for defaults expect no ramp
|
||||
dprintf(DEBUG_SPEW, "lm3534: setting backlight controller %u to level %u\n", i, backlight_level);
|
||||
data[0] = LM3534_GPR;
|
||||
data[1] = target_lm3534_gpr(i);
|
||||
|
||||
// <rdar://problem/20615779>
|
||||
// Dark boot may hand off to the OS with backlight disabled, but the OS backlight driver depends on iBoot
|
||||
// to configure the backlight even if it's left disabled.
|
||||
if (backlight_level == 0)
|
||||
data[1] &= ~0x1; // bit 0: chip enable
|
||||
|
||||
iic_write(lm3534_bus[i], lm3534_address[i], data, 2);
|
||||
|
||||
uint32_t thresholdValue = 0;
|
||||
if(mib_exists(kMIBTargetBacklightAutoFreqThresh, &thresholdValue)) {
|
||||
dprintf(DEBUG_SPEW, "lm3534: Modify Auto-Frequency Threshold (0x%x)\n", thresholdValue);
|
||||
data[0] = LM3534_AFT;
|
||||
data[1] = thresholdValue;
|
||||
iic_write(lm3534_bus[i], lm3534_address[i], data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// <rdar://problem/11055346> Not seeing the battery trap icon
|
||||
// Delay to ensure that the LM3534 settings are processed before issuing dwi transaction
|
||||
spin(600);
|
||||
|
||||
extern int dwi_send_backlight_command(uint32_t backlight_command, uint32_t backlight_level);
|
||||
|
||||
dwi_send_backlight_command(0xA, backlight_level);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2011-2015 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
OPTIONS += \
|
||||
WITH_HW_LM3534=1
|
||||
|
||||
LIBRARY_MODULES += drivers/backlight/lm3534
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
#include <debug.h>
|
||||
#include <drivers/iic.h>
|
||||
#include <target/gpiodef.h>
|
||||
#include <sys/task.h>
|
||||
#include "lp8559.h"
|
||||
|
||||
static bool lp8559_probed;
|
||||
static bool lp8559_present;
|
||||
|
||||
int beacon_reg_read(uint8_t reg_offset, uint8_t *value)
|
||||
{
|
||||
int status;
|
||||
status = iic_read(BACKLIGHT_IIC_BUS, lp8559_IIC_ADDRESS, ®_offset, 1, value, 1, IIC_NORMAL);
|
||||
return status;
|
||||
}
|
||||
|
||||
int beacon_reg_write(uint8_t reg_offset, uint8_t value)
|
||||
{
|
||||
int status;
|
||||
uint8_t data[2] = {reg_offset, value};
|
||||
status = iic_write(BACKLIGHT_IIC_BUS, lp8559_IIC_ADDRESS, data, 2);
|
||||
return status;
|
||||
}
|
||||
|
||||
int lp8559_backlight_enable(uint32_t backlight_level)
|
||||
{
|
||||
uint8_t cmd, epromid;
|
||||
|
||||
if (!lp8559_probed) {
|
||||
// Probe for the lp8559 by reading a register
|
||||
if (beacon_reg_read(lp8559_COMMAND, &cmd) == 0) {
|
||||
// Mark the lp8559 as present
|
||||
lp8559_present = true;
|
||||
}
|
||||
|
||||
// Mark the lp8559 as probed
|
||||
lp8559_probed = true;
|
||||
}
|
||||
|
||||
// Return an error if the lp8559 is not present
|
||||
if (!lp8559_present) {
|
||||
dprintf(DEBUG_INFO, "failed to detect lp8559, bailing\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Workaround for chips with EPROMID = 0x0
|
||||
// <rdar://problem/13700089> J85: Need to update register values in Beacon
|
||||
beacon_reg_read(lp8559_EPROMID, &epromid);
|
||||
if (epromid == 0x10) {
|
||||
// Unlock protected registers
|
||||
beacon_reg_write(lp8559_LOCK, 0xCF);
|
||||
|
||||
// Set inductor current limit to 2.2A
|
||||
beacon_reg_write(lp8559_CONFIG, 0x62);
|
||||
|
||||
// Set IMAX to 20mA:
|
||||
beacon_reg_write(lp8559_CURRENT, 0x02);
|
||||
|
||||
// Set PWM cutover point to 1mA
|
||||
beacon_reg_write(lp8559_HYBRIDLO, 0x33);
|
||||
|
||||
// Set SLOPE and VERT headroom control
|
||||
beacon_reg_write(lp8559_VHR1, 0x26);
|
||||
|
||||
// Set PWM global offset
|
||||
beacon_reg_write(lp8559_TRIM9, 0x08);
|
||||
|
||||
// Lock protected registers
|
||||
beacon_reg_write(lp8559_LOCK, 0x00);
|
||||
}
|
||||
|
||||
beacon_reg_read(lp8559_COMMAND, &cmd);
|
||||
|
||||
|
||||
// <rdar://problem/20615779>
|
||||
// Dark boot may hand off to the OS with backlight disabled, but the OS backlight driver depends on iBoot
|
||||
// to configure the backlight even if it's left disabled.
|
||||
|
||||
// read modify write
|
||||
// Bit 0 - on, Bit 3 - enable DWI
|
||||
cmd |= 0x9;
|
||||
if (backlight_level == 0) {
|
||||
cmd &= ~(0x9);
|
||||
}
|
||||
|
||||
// Configure the backlight for defaults expect no ramp
|
||||
beacon_reg_write(lp8559_COMMAND, cmd);
|
||||
|
||||
// IS this Required ??
|
||||
// <rdar://problem/11055346> Not seeing the battery trap icon
|
||||
// Delay to ensure that the lp8559 settings are processed before issuing dwi transaction
|
||||
task_sleep(600);
|
||||
|
||||
extern int dwi_send_backlight_command(uint32_t backlight_command, uint32_t backlight_level);
|
||||
|
||||
dwi_send_backlight_command(0xA, backlight_level);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
#ifndef __DRIVERS_LP8559_H
|
||||
#define __DRIVERS_LP8559_H
|
||||
|
||||
#define lp8559_IIC_ADDRESS (0x4C)
|
||||
|
||||
#define lp8559_COMMAND (0x00)
|
||||
#define lp8559_LOCK (0x0F)
|
||||
#define lp8559_CONFIG (0x10)
|
||||
#define lp8559_CURRENT (0x11)
|
||||
#define lp8559_BCFG1 (0x15)
|
||||
#define lp8559_BCFG2 (0x16)
|
||||
#define lp8559_BCFG3 (0x17)
|
||||
#define lp8559_BCFG5 (0x19)
|
||||
#define lp8559_HYBRIDLO (0x1A)
|
||||
#define lp8559_VHR1 (0x1E)
|
||||
#define lp8559_BCTRL (0x20)
|
||||
#define lp8559_TRIM2 (0x51)
|
||||
#define lp8559_TRIM5 (0x54)
|
||||
#define lp8559_TRIM9 (0x58)
|
||||
#define lp8559_LEDCFG (0xE6)
|
||||
#define lp8559_TMLOCK (0xEE)
|
||||
#define lp8559_EPROMID (0xFC)
|
||||
|
||||
int beacon_reg_read(uint8_t reg_offset, uint8_t *value);
|
||||
int beacon_reg_write(uint8_t reg_offset, uint8_t value);
|
||||
|
||||
#endif /* __DRIVERS_LP8559_H */
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2013 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
OPTIONS += \
|
||||
WITH_HW_LP8559=1
|
||||
|
||||
ALL_OBJS += \
|
||||
$(LOCAL_DIR)/lp8559.o
|
||||
Reference in new issue
Block a user