|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. ~7 W: f% u5 ~8 E! ]#include <linux/init.h>( u$ |9 [: B1 q! N0 t) V3 Z
#include <linux/module.h>, M$ l0 R5 N9 _
#include <linux/kernel.h>
4 P! g1 ~, E# ]' _* D s4 R/ `#include <linux/types.h>! h2 ]' T' p- @6 N9 I0 i1 _) ~* c
#include <linux/gpio.h>- }, r! T" u( M; p4 {. r8 M
#include <linux/leds.h>, j4 C$ ^" s- S7 G) T' E* q' ?; h
#include <linux/platform_device.h>$ l a$ U/ j/ R$ T6 I* B* v( A$ }
- m( k& L# G# i* x+ ~' j5 B#include <asm/mach-types.h>
; P/ u) `! c1 h: o$ g/ B& m4 `- N$ ]#include <asm/mach/arch.h>( {- d& k8 i( |- N
#include <mach/da8xx.h>% U- U# X5 E, i3 q# D5 [7 P
#include <mach/mux.h>
3 I# ]2 a3 n8 ~0 r6 ]. y" ]
3 T/ R7 r" [0 I+ I+ T3 N% O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( C7 T3 e0 k0 M) _/ O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 _5 N, |7 a9 [4 b" u- a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 w2 L5 P8 U' d+ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 @: p4 Y: N4 i/ E6 [
6 ]" p r* t' D% G
/* assign the tl som board LED-GPIOs*/, i; B: t' [, R
static const short da850_evm_tl_user_led_pins[] = {" L1 e5 A6 m6 s! K0 R6 {4 i/ t
/* These pins are definition at <mach/mux.h> file */' e0 _- o0 {: q2 r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 V+ k& t' p+ e* p -1
7 e7 j% g9 G* m6 v: w: \ C, h};
+ E0 M; G- N% R& B z' G+ R: p3 {; s9 M% Y+ l3 G
static struct gpio_led da850_evm_tl_leds[] = {8 ^ d6 j9 Y+ k
{( r( ] U7 v. d$ |4 p: E
.active_low = 0,3 v( c! `7 L4 l" Y* O `
.gpio = DA850_USER_LED0,! f. ]) c$ `3 {# K5 g
.name = "user_led0",
4 L# p' I/ X5 v* A$ B9 R6 B% ^ .default_trigger = "default-on",) v; [! m6 R! ~$ `6 z& P
},
8 a1 y( D* ^9 L$ k5 C6 Q {
% V4 P: L5 x5 l1 W8 x .active_low = 0,# l' z& y9 T2 N# b+ z
.gpio = DA850_USER_LED1,! f1 K/ L: s3 [- S5 Q
.name = "user_led1",
- L% |; d- O2 L2 e; {" ^ .default_trigger = "default-on", k A, i9 X ?1 z% O
},
0 Y c$ I/ L# F+ Q% Y {
1 ]/ {& m7 N9 |3 V: c8 v3 [# o5 C! t .active_low = 0,; h5 ~ c; ?1 P0 O" K* s A( b
.gpio = DA850_USER_LED2,. d( N0 J U! [( f% M
.name = "user_led2",2 c# `9 Z. v* l+ f( |4 _7 I# v; y k
.default_trigger = "default-on",/ E" ]" y- Y8 Y/ ^
},. Z% e/ P( w: L
{
4 Z3 A9 V7 c0 I. d .active_low = 0,* t o# r6 S* E" B
.gpio = DA850_USER_LED3,
/ r5 r7 C2 v6 ]% o" o6 B# G2 h6 e .name = "user_led3",
1 W- Q3 X) d: W) X. V$ ]; \0 O9 J .default_trigger = "default-on",
. J: F* G3 n l) q- q },8 R2 V2 o; r# o4 P1 r+ I7 V
};: E- u9 v2 X! v8 N
1 v3 q& U3 F: `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 F% s, F) L+ M+ L .leds = da850_evm_tl_leds,8 k% ?( e1 c i5 B5 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: A8 B# ^' V$ i/ y
};# ?' E/ K; X- k- d: t: k5 q2 m
" b0 m1 ?$ `6 `8 q0 y
static void led_dev_release(struct device *dev)3 _, y! k" I( f% H( J' D
{
% S% p$ D4 J+ S* U! p% x x2 y};
, e1 F- ?, T* i4 g* q
% s# H$ }: @' j; |$ w9 tstatic struct platform_device da850_evm_tl_leds_device = {
* k0 C0 _, U; O- z h5 Q. O4 Z .name = "leds-gpio",2 H8 \* U1 [! O8 ~. `2 h& ~8 w
.id = 1,
/ b! c6 {5 I k2 ? .dev = {- \6 c- E" v. Q0 I; F2 g# u
.platform_data = &da850_evm_tl_leds_pdata,
! h" t* J6 \0 e) J .release = led_dev_release,2 T1 r; a H( W7 M" I: e
}4 w# r5 b# F: Z! d! e0 }
};
4 k P+ Q+ ]3 E+ ~1 w
9 x9 [) M8 a5 X( ?4 N9 [static int __init led_platform_init(void)& D+ V( A: _) ], p8 x4 K
{
4 t# k" j. D0 A( g3 L6 P. ] int ret;5 S6 v" r% j4 @ \8 }" l
#if 0! K4 O+ y' ^) `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% K0 y" J& A( }0 F/ k* x
if (ret)
/ N5 c; H/ T: Q" [$ ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 h( Y) g& B/ [ "%d\n", ret);
+ |" X- {* Y8 z#endif
- d: S5 [; f# m: @7 `1 m ret = platform_device_register(&da850_evm_tl_leds_device);( d- A2 M" ^( W! {) ?; B
if (ret)
2 @2 J% J" P, K# K) n pr_warning("Could not register som GPIO expander LEDS");
9 K# x) W' Z5 k+ ~ else
9 G/ |2 e4 z) ^0 O" ]% L printk(KERN_INFO "LED register sucessful!\n");) B2 a/ _+ k% Y) C1 Z$ s
" i+ |1 G$ N% I; j6 n5 [ return ret;- R, _- J* }- H: w) I! T! d
}
! ^/ x, ?# V3 [' p7 {4 P# E& ]% {8 o. i+ ?; u
static void __exit led_platform_exit(void)
8 ^0 |3 J$ U1 r2 R4 ?" N' S* K5 y{
# Z$ B2 P3 M8 w" x: o, B platform_device_unregister(&da850_evm_tl_leds_device);2 a/ b3 p& a# ?* F9 T
0 f | B1 t9 N8 g9 d3 X1 H. n
printk(KERN_INFO "LED unregister!\n");
# f( L' g7 l& T* U( N. K. A}
% H1 Y6 ]+ G8 j' f* _$ z) e! c. V/ _. {/ V$ j. @! ?3 I7 w
module_init(led_platform_init);
- N) ~* z5 e( h5 S3 w# ~0 \module_exit(led_platform_exit);
* [* {8 S' u2 }3 ^8 ^0 J8 F
0 K' u' v% {; {0 p6 cMODULE_DESCRIPTION("Led platform driver"); l0 _; B- ~# P8 c0 i' p
MODULE_AUTHOR("Tronlong");
' d8 [' a/ S7 B3 X. E( q1 IMODULE_LICENSE("GPL");
5 H. E7 z, F0 W0 r+ d1 M, \2 F5 O. t3 F, q
|
|