|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- s' w6 I/ I- J
#include <linux/init.h>
, p! }( _" |5 v7 t1 T5 m: c#include <linux/module.h>" }9 V' Z3 e- z" ?9 [( g
#include <linux/kernel.h>' _3 Z2 n9 i c4 S( u
#include <linux/types.h>( Q# V1 o0 O/ p' G4 Y
#include <linux/gpio.h>$ K9 T# g7 s0 j* c% o. I
#include <linux/leds.h>
! G; r' V) O( A- a% a& P# u#include <linux/platform_device.h>
' Z; `8 ?' F {% g
^8 W- a; o: b$ l8 F#include <asm/mach-types.h>
+ L9 @- v; C X, ?8 v5 J" c4 i#include <asm/mach/arch.h>- x/ V1 \/ e" g* l, w9 W! ?/ Q
#include <mach/da8xx.h> X" i6 L) b' ?) F6 w4 X; I; m
#include <mach/mux.h>/ S9 i' L! J/ u$ m
/ R' Q" i, B: K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ I2 r$ g; s2 H7 X4 X0 n; p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ W( h0 j; A" r$ y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 L7 ?" o; B" s* E7 }* `) q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& k. l/ A. R2 i( p# y5 ` y1 e1 t f
/* assign the tl som board LED-GPIOs*/( r- B; F1 e0 i) o* `
static const short da850_evm_tl_user_led_pins[] = {; H* v" B; G! v. c
/* These pins are definition at <mach/mux.h> file */2 Z' |) A) L {1 W; W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ ]$ s2 U, j7 g! z9 M7 P
-1* n& A d' x/ j3 `$ e
};) l. ?2 A0 k* b; _) _
2 ]0 V: ] Y [7 @% X1 [
static struct gpio_led da850_evm_tl_leds[] = {
4 A% @% p% c: |+ _9 D! Z0 I7 b {/ q0 L/ f9 _8 I+ k) @, \% q
.active_low = 0,
! D9 u C1 { g# S! `5 I .gpio = DA850_USER_LED0,% c; }3 |3 m' |! a4 [
.name = "user_led0",
/ W B7 Z. j; J1 U .default_trigger = "default-on",3 O# U; \4 ?+ u% e# S
},8 M" G, E# d* A$ I! U# e
{& R7 h. z) z! i# o# q1 m$ L6 `
.active_low = 0,
& d1 C8 H& B6 m* Q: g2 g .gpio = DA850_USER_LED1,
5 O* p& m4 A9 q .name = "user_led1",1 ^8 d4 I' A& t" _, P" \
.default_trigger = "default-on",
5 |$ s0 D `1 S* m" d, v }," v) R, `6 z7 `$ [9 ~5 K4 J7 I
{) O, s4 V7 Q: ]9 ^6 ~5 m
.active_low = 0,
, `6 C7 o7 s: n1 `% j .gpio = DA850_USER_LED2,$ T2 j0 \8 h' Y- ?1 h0 v* s
.name = "user_led2",
$ _5 b/ B; T9 A, U9 r. z .default_trigger = "default-on",1 X0 w; Y0 ]6 s
},. u8 Z/ c8 V5 G: G$ c4 `# r6 O
{
( @2 U/ I! Z, K P- g/ F .active_low = 0,
x' W- `6 C8 Z6 C* Z7 ^6 G .gpio = DA850_USER_LED3," N! q( s. ~5 ?+ R6 e
.name = "user_led3",
* s. Y/ C) G2 _& k4 j2 C _: ~& g .default_trigger = "default-on",
& S! D0 w, Q' @. H" f* a },
0 V* B: `3 b4 B$ |5 a' \( D; c! L3 H}; w2 Y" L0 a% _% }. k* Z
% G) y* T. `7 i# m- l, d9 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) ^/ {& {9 s1 A3 p( C1 P
.leds = da850_evm_tl_leds,
# d& @; n6 }: F1 W7 f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) A# f9 M5 x% W9 I" D: _
};
3 @: _8 v# R- ?- Y: \0 F
: j2 M6 u* a6 j5 Mstatic void led_dev_release(struct device *dev)' a. o& m' w2 ~( i6 D S- x
{
, y2 E/ {% `8 w};
9 D/ F; _) l$ _4 [1 U8 S/ @2 R8 \$ _) [; s9 ^! ]" M0 R; b3 B5 a
static struct platform_device da850_evm_tl_leds_device = {
' i, k; E8 b) ?6 Z& Z, I/ g .name = "leds-gpio",$ ?0 u! q+ A* f& y% o, k
.id = 1,- b- V* R# d8 g' N
.dev = {$ C2 O) M- S' {1 I; R9 J
.platform_data = &da850_evm_tl_leds_pdata,4 y$ X5 V: Z" y2 b4 b4 w
.release = led_dev_release,. y$ N$ o% M; u h
}7 _7 o" }7 d* t. v# @$ l
};
. X0 _/ Y. j; W: s
3 z/ t. H( S, b% K7 [3 V. Astatic int __init led_platform_init(void)
2 A3 E) H$ ^$ \# [+ ^- K8 @% a. O{
1 e- }# @5 V% K& O' M int ret;
' w$ k" w1 ]" K* S' ~6 S; k! b6 ~#if 0
# H$ H2 X$ t/ w# \+ M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 }3 k4 V* Y! f7 n3 ^
if (ret)! p0 [1 U1 p2 X5 a$ d# U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 r7 z6 X. y! b$ I9 U8 l, l) d "%d\n", ret);
5 X# C: ?$ A6 Z( R8 h#endif
; U! G. Y8 e: y4 O- q; k- r2 Z ret = platform_device_register(&da850_evm_tl_leds_device);( k. A& _) b5 t! H% V
if (ret)8 c( K- I4 T, q4 J; j
pr_warning("Could not register som GPIO expander LEDS");4 \, \) j: b, A$ S3 J
else
: u# ^3 h2 X7 Y, }* ]+ F9 Y printk(KERN_INFO "LED register sucessful!\n");
* J7 q! p+ c) }6 `7 J- [6 [* c0 s- u0 U
return ret;# `) m" q# H, D/ R
}1 S+ i3 q: d: M3 r# @1 T
. t5 R9 z+ `! Q) @" q
static void __exit led_platform_exit(void)
5 k, b3 k- s( B, f3 n) E7 i+ {{
4 _2 ]$ q v7 U M9 `- S( c platform_device_unregister(&da850_evm_tl_leds_device);2 A5 V( a+ c# E3 z
' |1 u# ^- u; {7 P: x* M% N printk(KERN_INFO "LED unregister!\n");
Z# f; g1 y: C8 } I}$ J' L7 p' o$ S; J: J( A
# x$ d0 B: B7 G& Emodule_init(led_platform_init);* b. ^4 z; f7 o y
module_exit(led_platform_exit);
7 X5 ]$ P& l0 Z# N1 l5 I( U6 o8 l5 N3 d. H% [8 y
MODULE_DESCRIPTION("Led platform driver");5 p/ h) K% W! z' P% r6 F
MODULE_AUTHOR("Tronlong");
+ R( G7 @! k8 e& t% }' rMODULE_LICENSE("GPL");
. a, E" m ?7 w3 W$ B8 J1 u* V E5 m A
|
|