|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! b+ T! U* ?1 j8 T7 |3 d' F
#include <linux/init.h>9 b+ o' B9 W9 I/ c! b
#include <linux/module.h>
- b8 X# p# G, v! f, m#include <linux/kernel.h>
8 l" r& n v+ L: q) z#include <linux/types.h>, I6 k* D8 G0 g
#include <linux/gpio.h>( F" A& `9 @/ x- d
#include <linux/leds.h>
8 c z. ~. j- w& b; P$ S2 |#include <linux/platform_device.h>
) I/ R. g" p# I) O4 y! F# O& Z
7 a) m4 v# b+ w2 k k. F: d6 Q#include <asm/mach-types.h>
% \9 w# L" n2 S( d' e( d* k#include <asm/mach/arch.h>, p! H# j5 b, G( y, z
#include <mach/da8xx.h>
+ d: j5 G# p7 D$ {2 }/ s1 `#include <mach/mux.h>
9 `4 i$ I# x% ]9 u6 y
- Z" z3 M3 n3 J, I+ a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* {" o+ I& z% a7 P( b8 W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: U! `" y5 q) ?' }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 S" s+ H8 T/ z2 z7 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 g8 T8 y, q8 z7 L5 a
9 w7 S9 Y0 m- |/* assign the tl som board LED-GPIOs*/
, ?) i" n# g0 \3 e5 f. u0 Gstatic const short da850_evm_tl_user_led_pins[] = {
' W* E; K2 G" N /* These pins are definition at <mach/mux.h> file */# A: O: F# ?2 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) u- T9 P! A& u5 {* X -1- I7 b' _& f2 c( I. }# [
};
& G2 b, F9 L/ `/ s/ L9 L, P7 f1 w$ C/ o7 w: i3 J2 t
static struct gpio_led da850_evm_tl_leds[] = {3 Q! @' |4 S& z: B4 Q
{
* u; V7 i4 U6 ]* p, M) g .active_low = 0,
& w( A" m3 H) K2 R .gpio = DA850_USER_LED0,! Q) w1 d/ J! w4 `
.name = "user_led0",3 g4 j$ r6 Q# V; ]
.default_trigger = "default-on",+ V9 F0 e4 {6 ?; J, d% A
},
6 r6 }- q* O' A) C, p9 Y9 N {. S- L* u. y; D6 H
.active_low = 0,
" o7 t9 s$ }( Z. W .gpio = DA850_USER_LED1,
# m& ?1 ~6 X) J$ Y4 D' X .name = "user_led1",
* O+ h' r& e6 @: ? .default_trigger = "default-on",
j {. _0 D* A' l },
: v1 @5 X. P) K1 ? {
( x6 q! P [) \ .active_low = 0,# g8 M; s" W/ q1 k/ Q0 d; q
.gpio = DA850_USER_LED2,
6 i% G& j- V5 l .name = "user_led2",$ q: L3 x1 z% h* \
.default_trigger = "default-on",: K2 [& W4 |: e# Q1 p6 [
},. `. o2 c, o6 m7 S& b! S
{
; W; q7 `. d) ? .active_low = 0,$ b) h, y0 R: k
.gpio = DA850_USER_LED3,) Q% x5 J* \4 Q- x3 d
.name = "user_led3",
* Y% s* u+ Q7 V0 U4 a% h .default_trigger = "default-on",
7 m. n( g( C5 G3 l7 h },# y$ B( y7 @# c
};
8 j) h; I* L' a
) p+ n3 X6 q- L8 f3 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 a. J% U5 j$ J8 m( |: B1 E) `9 @ o) Q
.leds = da850_evm_tl_leds,
. n- @# Q" o# p& k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 G8 ~1 ]* p, ]* l' T+ A# Z8 D
};! k% t% s" h$ v+ l) ?
- C+ R5 T: l/ c! z) M9 v% O. U: f
static void led_dev_release(struct device *dev)) |' ]6 S" l3 j4 {# z% S' L
{
5 O& I4 E0 ?/ }0 \& f% q2 u1 ?+ v4 u};7 [0 R! |# I! ^4 a m6 T
# E, o: Y$ Y0 C6 V2 A
static struct platform_device da850_evm_tl_leds_device = {$ l0 U6 O9 M% j; f0 D. E
.name = "leds-gpio",. Z& m2 P8 S; N( |9 J# `
.id = 1,
* r. q& v7 ^0 n$ H/ ? .dev = {
% @0 M9 J+ o! `) G/ Q; e .platform_data = &da850_evm_tl_leds_pdata,5 m( Q6 w) I; ^7 `0 S
.release = led_dev_release,8 q+ D+ k% g$ W8 v5 \+ K
}
5 S- F$ g6 d' N};% R) L* k. o4 G$ S! P4 A) [* w
B* C i( V9 V) dstatic int __init led_platform_init(void); l( G( f. Z7 Q) B) z3 O5 h0 r) L
{
, j! g, O2 M. w8 E int ret;/ { I: m# E/ J
#if 08 k# @/ ~, [8 _ ~# y! k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 e% d) J) |5 c
if (ret)
: ^6 t! E* y1 Z' F' A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' J, h9 q7 g6 Y2 e' d' g3 _
"%d\n", ret);7 s3 H2 t4 J- V
#endif9 G2 d+ z/ l# ]9 c7 `
ret = platform_device_register(&da850_evm_tl_leds_device);
5 c+ n# p% d. r" ^* c9 A7 `; A if (ret)
- |+ T7 S4 A: y X9 K pr_warning("Could not register som GPIO expander LEDS");
! B0 j1 {* ?: r* Y else# U8 q4 G; V" r' j3 M6 u- y
printk(KERN_INFO "LED register sucessful!\n");
6 t# T- x6 p |9 \4 s. L; B T( E+ c
2 I# \) r8 q/ Q3 Q/ k return ret;
) y& L! O; b$ D) } t& F; ^}" w- L3 f$ b) \1 r' ?- F
3 i3 S# s3 \/ `, @$ Sstatic void __exit led_platform_exit(void)* S6 Q, Z" {+ O
{6 H' [0 c" G' [3 K% \
platform_device_unregister(&da850_evm_tl_leds_device);
' k) X; @0 {: T" p$ R; h
$ q, }5 K/ a N8 a9 j& M printk(KERN_INFO "LED unregister!\n");
1 l# R# o% r# T) k}- A4 u7 o: j* s& |2 g' C3 Y
5 D7 F6 M2 H, y( P' A: v$ ~! _6 G# vmodule_init(led_platform_init);& Y/ Q# W: A5 h) g" Y
module_exit(led_platform_exit);, D: ~. j$ {8 g* J- e
, L' I$ M5 T: `: m5 [MODULE_DESCRIPTION("Led platform driver");* [/ X( T4 I9 J$ L, t
MODULE_AUTHOR("Tronlong");- N; U! P6 W* S4 {, q
MODULE_LICENSE("GPL");
+ O: v0 F( W' M
. l4 r9 P7 k/ m1 A |
|