|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' [: Z6 P J( k#include <linux/init.h>
! j, Y. t- B) T0 m: s#include <linux/module.h>
I1 N, {* N8 S9 g% w#include <linux/kernel.h>& E# |/ r- z( V( Z3 |
#include <linux/types.h>" n9 l. ?" T( @( s! [
#include <linux/gpio.h>! M8 g7 b+ M' ~
#include <linux/leds.h>
3 H% D1 q1 R+ U$ Y3 n9 ?* b Y#include <linux/platform_device.h>
2 h( _4 a6 C* h7 T/ z+ W# c* o6 b. `* F# c* B. T- ]' V
#include <asm/mach-types.h>
5 x% }, h3 z3 A+ V3 Y( K* ^9 V#include <asm/mach/arch.h>
, I4 k- D/ v9 N: b5 }#include <mach/da8xx.h>
7 F' \) ]6 G5 z9 ~2 x#include <mach/mux.h>: Y3 i {& J+ b; N
p z# L6 b: [ J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 N* _' P" g, D9 A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ u3 O5 f" A, o) d3 ~( u: A0 g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- G8 k3 F' ?; G1 D+ S- N% r8 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& h: P" s$ C5 }+ @: C! A
3 \8 ~' A) y5 }/ ^. E) r/* assign the tl som board LED-GPIOs*/* r. {2 u' h$ ^6 f9 b* T+ \4 P6 ~
static const short da850_evm_tl_user_led_pins[] = {! b. }, l' `% I
/* These pins are definition at <mach/mux.h> file */; D5 B/ o4 B& a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ N7 M- m9 Q2 l& g -1+ Z8 ~) ]' N( R2 ~1 G7 r
};* Q$ p3 m- h. E+ c, h6 y: J
8 r: I. g: j* S7 Z" Kstatic struct gpio_led da850_evm_tl_leds[] = {1 Q1 p/ m# D2 P( Q, F% q
{( h; T- W4 m) @8 o2 i
.active_low = 0,
3 K- Z( Q( L# N6 g4 T4 t: u- A .gpio = DA850_USER_LED0,8 f9 F2 Z# ^! \1 K$ z
.name = "user_led0",, }+ H7 t+ F1 ~! d" [
.default_trigger = "default-on",
& e; q, w, `- T2 ^; x7 i% R },, E) j5 x t T+ Y& X* C) P" @# T' t
{
0 h: a3 z6 f* H [7 K% x7 S .active_low = 0,% g7 F( o, t- i' ^- F5 R
.gpio = DA850_USER_LED1,
1 [. `8 Q$ z. W4 `2 n .name = "user_led1",0 s8 ~( D( K4 d3 b' _/ i9 c
.default_trigger = "default-on",
. `) c9 W6 r8 { },/ h( S) K# d; d" W s
{
" l1 T; @# ~ j# W9 d .active_low = 0,
6 s, E$ q R4 H% _ .gpio = DA850_USER_LED2,
* y: ]3 X8 i9 u( U1 t ^ .name = "user_led2",
' r% b4 y. I1 |/ d .default_trigger = "default-on",
4 @' e9 v! B0 q+ D2 D+ _9 f/ n H8 g& S },
9 u; N1 P: U% U" r {! E6 c0 N2 T D1 {, `! K# U
.active_low = 0, [2 r& P) D4 ]1 S7 y
.gpio = DA850_USER_LED3,% K4 v3 h9 W/ F
.name = "user_led3",# F' I0 o- M& s, U0 u9 N; \
.default_trigger = "default-on",
$ o# L# i' j, H9 x& d2 ` },
4 l0 o: }, f4 C, ^8 w- h};9 ] o/ G: p3 B. R% T* @' u6 G, v# _
5 m8 a: Z/ B+ o. U$ z* {. q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ G% W$ e# |' v" @; `( I; Y' v
.leds = da850_evm_tl_leds,
8 ]0 E% g2 x5 x7 A) R) @/ l' r [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 i" K$ H3 N6 d
};; b3 \+ q+ ^8 {# J8 P
9 O6 ~( I. A' p6 N: m
static void led_dev_release(struct device *dev)
* K/ J1 T3 s! G* ?7 v{$ B* V* ~( F7 h8 g2 q6 z
};3 _" v- M# A3 M6 b1 l5 w
. T; [* a0 H, ^, n9 L) }" n5 f
static struct platform_device da850_evm_tl_leds_device = {
+ L6 h* X; L$ b0 U, P .name = "leds-gpio",/ Z; H! L. M& u6 f! H% s: J
.id = 1,
* F2 Y* z! X/ V! i- u1 d1 K( r; V .dev = {4 m- e! @7 T$ _0 A
.platform_data = &da850_evm_tl_leds_pdata,, L2 f" w: t% ?, l$ E
.release = led_dev_release,
+ _: v j a! t' N7 J9 C } ]4 i& g9 |+ g4 x( O
};
, m+ U0 P! t2 b/ b$ q* I1 K. B% H+ _1 R0 H9 Y
static int __init led_platform_init(void)
# v/ k$ z2 g7 r6 J+ Z{
* k! Z3 ?3 k* T1 }0 W int ret;! k) e: T( C) R5 d3 y
#if 0* @7 F+ u% Y* \0 B9 R2 @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, C2 f! t$ ^% Q8 j3 w2 s, n0 R* J! b if (ret)5 H2 G" S _2 m# a( v( O1 T8 Z" V( W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* D. j6 Q% E) F d "%d\n", ret);
4 \& _$ Q7 |' K2 q. m* W) h5 O#endif
: C% C9 U7 M8 P4 c ret = platform_device_register(&da850_evm_tl_leds_device);. `: w& j4 `) Z3 l0 L3 H
if (ret): s% i& L, c3 @
pr_warning("Could not register som GPIO expander LEDS");; w% h( r2 w/ N* {: K' e o
else
! @$ d$ Q+ E) ? G' i7 ]; T$ O' d* a+ c printk(KERN_INFO "LED register sucessful!\n");- o: @+ H% d6 O. Y n
: ?+ Z4 m: J: W return ret;
7 V3 `8 s' F! Z& [}
5 U8 p" B: J3 S6 d( U: n. A2 @7 e6 L3 E0 n I: D
static void __exit led_platform_exit(void)
+ M/ x4 l( X/ u! N{9 n: ^3 @, o% f+ t: _( B% F9 k' d
platform_device_unregister(&da850_evm_tl_leds_device);# \; I- U6 B5 C! X# ^
" @3 K1 A9 S. m0 c
printk(KERN_INFO "LED unregister!\n");/ a2 P) j# O1 U' z
}
) {1 D/ V. b6 s- p" R( ]* s- [/ A& C3 ?7 ` H5 Y
module_init(led_platform_init);
" p5 u2 C5 T5 ~. I u; [7 omodule_exit(led_platform_exit);
# t2 W) l, z- n& \; G3 u; ~8 [! d u
0 [ \$ `2 R4 b3 R1 B" kMODULE_DESCRIPTION("Led platform driver");4 v" Z+ c) h& n' c4 P( U5 e
MODULE_AUTHOR("Tronlong");
6 p8 S7 b3 ]" \) ?* fMODULE_LICENSE("GPL");
7 X7 N& B& ?2 _$ G$ a Y, ^! Q1 n6 \2 V' S+ w
|
|